Tải bản đầy đủ

Professional Silverlight 4 docx

www.it-ebooks.info
www.it-ebooks.info
PROFESSIONAL SILVERLIGHT
®
4
INTRODUCTION xxv
CHAPTER 1 Introduction to Silverlight 1
CHAPTER 2 Building Applications with Visual Studio . . . . . . . . . . . . . . . . . . . . . . . . . .31
CHAPTER 3 Building Applications with Expression Blend 4 . . . . . . . . . . . . . . . . . . . . 63
CHAPTER 4 Working with the Navigation Framework . . . . . . . . . . . . . . . . . . . . . . . . . 93
CHAPTER 5 Controlling Layout with Panels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
CHAPTER 6 Working with Visual Controls 139
CHAPTER 7 Accessing Data 205
CHAPTER 8 WCF RIA Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
CHAPTER 9 Out-of-Browser Experiences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
CHAPTER 10 Networking Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 301
CHAPTER 11 Building Line of Business Applications . . . . . . . . . . . . . . . . . . . . . . . . . . 337
CHAPTER 12 Application Architecture 375
CHAPTER 13 DOM Interaction 429
CHAPTER 14 Securing Your Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449
CHAPTER 15 Accessing Audio and Video Devices 479

CHAPTER 16 Working with File I/O 497
CHAPTER 17 Using Graphics and Visuals 541
CHAPTER 18 Working with Animations in Silverlight 591
CHAPTER 19 Working with Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 613
CHAPTER 20 Making It Richer with Media 641
CHAPTER 21 Styling and Themes 681
APPENDIX A XAML Primer 723
APPENDIX B Testing Silverlight Applications 741
APPENDIX C Building Facebook Applications with Silverlight . . . . . . . . . . . . . . . . . . 757
APPENDIX D Integrating Silverlight into SharePoint 2010 . . . . . . . . . . . . . . . . . . . . . . 775
APPENDIX E Silverlight Control Assemblies 783
INDEX 787
www.it-ebooks.info
www.it-ebooks.info
PROFESSIONAL
Silverlight
®
4
Jason Beres
Bill Evjen
Devin Rader
www.it-ebooks.info
Professional Silverlight® 4
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-65092-9
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of
the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923,
(978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions
Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or
online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work
is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should be sought. Neither
the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is
referred to in this work as a citation and/or a potential source of further information does not mean that the author
or the publisher endorses the information the organization or Web site may provide or recommendations it may make.
Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between
when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available
in electronic books.
Library of Congress Control Number: 2010930723
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress
are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other
countries, and may not be used without written permission. Silverlight is a registered trademark of Microsoft Corporation
in the United States and/or other countries. All other trademarks are the property of their respective owners. Wiley
Publishing, Inc., is not associated with any product or vendor mentioned in this book.
www.it-ebooks.info
To my beautiful wife Sheri and our amazing 4-year-old
daughter Siena for supporting me during the late nights and
weekends that it took to get this book completed.
— Jason Beres
To George — glad you made it to the developer ranks, brother!
— Bill Evjen
To Mom and Dad, thanks for everything!
— Devin Rader
www.it-ebooks.info
www.it-ebooks.info
ABOUT THE AUTHORS
JASON BERES is the Vice President of Product Management, Community, and
Evangelism, and spearheads customer-driven, innovative features and functionality
throughout all of Infragistics’ products. Jason is a Microsoft .NET MVP for
8 years running, a member of the INETA Speakers Bureau, and is the author
of 7 books on various .NET technologies, the latest being this one, Professional
Silverlight 4 from Wrox Press.
BILL EVJEN is an active proponent of .NET technologies and community-based
learning initiatives for .NET. He has been actively involved with .NET since the
first bits were released in 2000. In the same year, Bill founded the St. Louis .NET
User Group (
www.stlnet.org), one of the world’s first such groups. Bill is also
the founder and former executive director of the International .NET Association
(
www.ineta.org), which represents more than 500,000 members worldwide. Based in St. Louis,
Missouri, Bill is an acclaimed author and speaker on ASP.NET and Services. He has authored or
coauthored more than 20 books including Professional C# 4 and .NET 4, Professional ASP.NET 4
in VB and C#, ASP.NET Professional Secrets, XML Web Services for ASP.NET, and Web Services
Enhancements: Understanding the WSE for Enterprise Applications (all published by Wiley). In addi-
tion to writing, Bill is a speaker at numerous conferences, including DevConnections, VSLive!, and
TechEd. Along with these items, Bill works closely with Microsoft as a Microsoft Regional Director
and an MVP. Bill is the Global Head of Platform Architecture for Thomson Reuters, Lipper, the
international news and financial services company (
www.thomsonreuters.com). He graduated from
Western Washington University in Bellingham, Washington. When he isn’t tinkering on the computer,
he can usually be found in his summer house in Toivakka, Finland. You can reach Bill on Twitter
at
@billevjen.
DEVIN RADER works at Infragistics where he focuses on delivering great user experi-
ences to developers using their controls. He’s done work on all of the .NET platforms,
but most recently has been focused on ASP.NET and Silverlight. As a co-founder of
the St. Louis .NET User Group, a current board member of the Central New Jersey
.NET User Group, and a former INETA board member, he’s an active supporter of the
.NET developer community. He’s also the co-author or technical editor of numerous books on .NET
including Silverlight 3 Programmer’s Reference and Professional ASP.NET 4 in C# and VB from
Wrox. Follow Devin on Twitter
@devinrader.
www.it-ebooks.info
ABOUT THE CONTRIBUTORS
SHAWN ANDERSON is currently a senior solutions architect with Infragistics and spends much of his
time working on designing and developing business solutions and new product lines that utilize cut-
ting edge technology in combination with the latest Infragistics suites and tools. He has a passion
for all things technical and has been designing and developing large scale business systems across
multiple platforms for over 15 years.
GRANT HINKSON serves as a bridge between design and development in Microsoft’s Entertainment
Experience Group as an Experience Developer, focused on the Zune PC Client. Grant has a history of
uniting design and development and has pioneered integrated workflows across multi-discipline teams.
He is an advocate for iterative design and rapid prototyping and believes Silverlight is an enabling tech-
nology that supports those processes. Before joining Microsoft, Grant founded and grew the Experience
Design Group at Infragistics. He has been honored as a Microsoft Expression MVP and has spoken at
Microsoft Mix, Microsoft ReMix, Adobe MAX, and Devscovery. Grant is a contributing author on the
Wrox titles Silverlight 1.0, Silverlight 3 Programmer’s Reference, and the Friends of Ed title Foundation
Fireworks CS4. He has authored a number of utilities for the designer/developer community, notably
the Fireworks to XAML exporter. You can find Grant’s latest creations at
www.granthinkson.com.
DAVID KELLEY has been building targeted customer experiences primarily on the web and offline
for over 10 years. David’s main focus is on integrating technology into environments, ranging from
using sensors to touch screens and Silverlight. David is currently the Principal User eXperience
Architect for Wirestone and publishes a blog “Hacking Silverlight” as well as posts related to UX
for Interact Seattle. Currently his main focus is in the retail space with touch experiences such as
digital price tags and Silverlight-based kiosks. David’s other career highlights include the Silverlight
Bill Gates demo at TechEd ‘08, the Entertainment Tonight Emmy Award site for the Silverlight
launch, and achievement of a Silverlight MVP in 2009, as well as his work with Wirestone. In his
spare time David helps run Interact (Seattle’s Designer Developer Interaction Group and the Seattle
Silverlight User Group), travels, plays with his kids, Legos, and more.
MIHAIL MATEEV is a senior software development engineer with Infragistics, Inc. He worked as
a software developer and team lead on WPF and Silverlight Line of Business production lines of
the company and now works as a Technical Evangelist. Over the past 10 years, he has written
articles for Bulgarian ComputerWorld magazine as well as blogs about .NET technologies. Prior
to Infragistics, he worked at ESRI Bulgaria as a software developer and a trainer. For several years
Mihail has delivered lectures about geographic information systems for the Sofia University “St.
Kliment Ohridski” Faculty of Mathematics and Informatics. Mihail is also a lecturer on computer
systems for the University of the Architecture, Civil Engineering and Geodesy in Sofia, Bulgaria,
in the Computer Aided Engineering Department. Mihail holds master’s degrees in Structural
Engineering and Applied Mathematics and Informatics.
www.it-ebooks.info
TODD SNYDER is a solution architect and developer with over 15 year of experience building enter-
prise and rich Internet (RIA) applications on the Microsoft platform. He currently is a principal
consultant on the Infragistics UI Service team specializing in RIA and Enterprise application archi-
tecture. He is the co-leader for the New Jersey .NET user group (
www.njdotnet.net/) and is a
frequent speaker at trade shows, code camps, and Firestarters.
ABOUT THE TECHNICAL EDITORS
STEPHEN ZAHARUK graduated with a B.S. in Computer Science from Susquehanna University in 2004.
Since then he’s been working at Infragistics, first working in their Developer Support department and
soon writing new UI controls for their ASP.NET product line. When Silverlight was announced, Steve
joined a new team for the Infragistics Silverlight Line of Business product line as Team Lead and soon
after as Product Architect.
TODD SNYDER See Todd Snyder’s bio in the preceding “About the Contributors” section.
MATTHEW VAN HORN specializes in rapid development focused on flexible and dynamic code to leverage
maximum results with minimal effort. His development tool of choice is Silverlight, which he has used
in projects ranging from a clone of Space Invaders for Facebook to back office accounting to a dynamic
business intelligence visualization system that turned heads at the Global Gaming (casino) Expo this
year in Las Vegas, Nevada.
CRAIG SELBERT currently works for Thomson Reuters, Lipper (www.lipperweb.com), as a Senior
Software Developer. His primary responsibilities are developing web frameworks and applications using
various rich Internet application toolsets like ASP.NET, jQuery, ASP.NET MVC, Silverlight, Unity, and
Prism. At Lipper, Craig works on a team that created a framework leveraging the Unity/Prism frame-
work in Silverlight and WPF that has allowed them to build true enterprise module-based applications.
He has always been an early adopter of technology that has growing pains, but through perseverance,
the software and Craig have always come out better in the end. Craig enjoys spending most of his work-
ing time dealing with Microsoft technologies, but keeps a watchful eye on other technologies to make
sure he stays well rounded. You can reach Craig on Twitter at
@craigselbert.
www.it-ebooks.info
CONTRIBUTORS
Shawn Anderson
Grant Hinkson
David Kelley
Mihail Mateev
Todd Snyder
EXECUTIVE EDITOR
Robert Elliott
SENIOR PROJECT EDITOR
Kevin Kent
DEVELOPMENT EDITOR
Je Riley
TECHNICAL EDITORS
Steve Zaharuk
Todd Snyder
Matthew Van Horn
Craig Selbert
SENIOR PRODUCTION EDITOR
Debra Banninger
COPY EDITORS
Kim Cofer
Cate Carey
EDITORIAL DIRECTOR
Robyn B. Siesky
EDITORIAL MANAGER
Mary Beth Wakefield
MARKETING MANAGER
Ashley Zurcher
PRODUCTION MANAGER
Tim Tate
VICE PRESIDENT AND EXECUTIVE GROUP
PUBLISHER
Richard Swadley
VICE PRESIDENT AND EXECUTIVE PUBLISHER
Barry Pruett
ASSOCIATE PUBLISHER
Jim Minatel
PROJECT COORDINATOR, COVER
Lynsey Stanford
COMPOSITORS
Je Lytle, Happenstance Type-O-Rama
Craig Woods, Happenstance Type-O-Rama
PROOFREADER
Nancy Carrasco
INDEXER
Robert Swanson
COVER DESIGNER
Michael E. Trent
COVER IMAGE
© pederk/istockphoto
CREDITS
www.it-ebooks.info
ACKNOWLEDGMENTS
I WOULD LIKE TO THANK THE ENTIRE TEAM AT WROX, especially Kevin Kent, our Senior Project
Editor, and Bob Elliott, our Executive Editor, who kept this book on schedule on a tight timeline.
You guys really pulled the team together to make this happen. Thank you. I would recommend
Kevin for Project Editor of the Year if there was such an award. I’d also like to thank my two awe-
some co-authors, Bill and Devin. It was a pleasure working with you on the book, and I hope we
can do more in the future. And last but not least, Todd Snyder, Matt Van Horn, Stephen Zaharuk,
Craig Selbert, Mihail Mateev, Shawn Anderson, David Kelley, and Grant Hinkson — you guys
wrote chapters and gave technical guidance, and without you, this book wouldn’t have the backbone
that it does. Thanks for the hard work in making this book a reality.
— Jason Beres
THANKS TO KEVIN KENT, BOB ELLIOTT, AND JIM MINATEL for the opportunity to work on such a
great book. I also want to thank my co-authors who have also been very longtime friends of mine
and guys that have been making this .NET journey with me since the first days. I would also like
to thank my family for putting up with another writing project (as this takes away many weekends
from their time with me). Thank you, Tuija, Sofia, Henri, and Kalle!
— Bill Evjen
THANKS TO JIM MINATEL, BOB ELLIOT, KEVIN KENT, PAUL REESE, and everyone at Wrox for helping us
make this book happen. Thanks to Shawn Anderson, Grant Hinkson, David Kelley, Mihail Mateev,
and Todd Snyder for contributing to the book. Each one of you brought your unique talents to the
content of this book, and it’s better for that. Thanks to Steve, Todd, Matt, and Craig for your techni-
cal feedback and advice. A huge thanks to Jason and Bill. Jason, this is our second Wrox collaboration
and, Bill, this is our fifth, and it’s awesome working with you guys. Finally a special thanks to my wife,
Kathleen, who continues to support and tolerate my writing despite the late nights and long weekends.
— Devin Rader
www.it-ebooks.info
www.it-ebooks.info
CONTENTS
INTRODUCTION xxv
INTRODUCTION TO SILVERLIGHT CHAPTER 1: 1
What Is Silverlight? 2
Silverlight Versions Explained 5
Application Development Scenarios 6
Getting the Silverlight Plug-In 8
Getting the Silverlight SDK 11
Building Silverlight Applications 12
Silverlight 4 Tour 12
XAML 13
.NET Framework Support 14
Graphics and Animations 15
Page Layout and Design 18
User Interface Controls 20
Using Media in Silverlight 21
Local Data Storage 22
Out-of-Browser Experiences 22
Local Filesystem Access 23
Navigation Framework 23
Annotation and Ink 24
Accessing the Network 25
Data Binding 26
Printing 27
Drag-and-Drop 27
Clipboard Access 27
Deep Zoom Graphics 28
Summary 29
BUILDING APPLICATIONS WITH VISUAL STUDIO 3CHAPTER 2: 1
Creating a Basic Silverlight Application 31
Using Silverlight Designer for Visual Studio 35
Creating Silverlight Project and Web Application Project Files 40
Using the Silverlight Design Surface 41
Understanding the XAP File 47
www.it-ebooks.info
xiv
CONTENTS
Caching Assemblies 50
Adding Class Definition and Partial Classes 52
Understanding the Application Life Cycle 55
Debugging Silverlight Applications 57
Attaching to a Process to Debug 57
Attaching to a Remote Macintosh Process 59
Configuring Silverlight MIME Types 61
Adding MIME Support to IIS 61
Summary 62
BUILDING APPLICATIONS WITH EXPRESSION BLEND 4 6CHAPTER 3: 3
Learning Expression Blend Basics 64
IDE Tour 64
Creating Your Own Silverlight Project 77
Using Expression Blend Behaviors 78
Implementing Behaviors 78
Consuming Behaviors 80
Using the Visual State Manager 81
Creating a Control Template(s) 81
Customizing Visual States 83
Importing Design Assets 83
Importing PhotoShop (PSD) Assets 84
Importing Illustrator (AI) Files 85
Importing Fonts and Images Assets 85
Using the Expression Suite 86
Expression Encoder 87
Deep Zoom Composer 87
Summary 91
WORKING WITH THE NAVIGATION FRAMEWORK 9CHAPTER 4: 3
Using the Navigation Template 93
Creating Parameterized Query Strings 99
Using the Frame Class 105
Using a Custom Menu Control 111
Adding Navigation Animations 113
Summary 115
CONTROLLING LAYOUT WITH PANELS 11CHAPTER 5: 7
Measure, Then Arrange 118
Element Sizing Characteristics 120
Height and Width 120
www.it-ebooks.info
xv
CONTENTS
Alignment 123
Margin and Padding 123
Using Layout Panels 125
Canvas 126
StackPanel 127
VirtualizingStackPanel 128
Grid 129
WrapPanel 131
DockPanel 132
Finding Third-Party Panels 133
Creating Custom Panels 133
Silverlight Plug-In Sizing 137
Summary 138
WORKING WITH VISUAL CONTROLS 13CHAPTER 6: 9
Where to Find Controls 140
Using Text Display Controls 142
TextBlock 142
Label 143
Using Input Editor Controls 144
Text 144
Using Numeric Editor Controls 147
Dates and Time 150
Using Lists and Items Controls 154
DataGrid 154
DataForm 162
ListBox, ComboBox, and TabControl 163
DataPager 169
Accordion 170
TreeView 172
Using Button Controls 175
Button 175
HyperlinkButton 177
ToggleButton 177
Using the GridSplitter Control 178
Using the Image Control 179
Using Data Visualization Controls 180
TreeMap 180
Chart 185
www.it-ebooks.info
xvi
CONTENTS
Using Other Miscellaneous Controls 189
ViewBox 189
BusyIndicator 190
Expander 192
ValidationSummary 192
Tooltip 193
ScrollViewer 194
Creating Custom Controls 195
Template Parts 200
Visual States 201
Summary 203
ACCESSING DATA 20CHAPTER 7: 5
Processing XML Data 205
LINQ to XML 206
Using an XmlReader 208
Binding a User Interface to Data 209
Establishing a Data-Binding Connection 209
Handling Data Updates 215
Converting Data Types 222
Working with Services 225
Building an ASP.NET Web Service 227
Consuming a Simple XML Web Service 234
Working with Windows Communication Foundation (WCF) 238
Working with REST-Based Services 247
Summary 255
WCF RIA SERVICES 25CHAPTER 8: 7
Understanding WCF RIA Services 258
Building a Simple RIA Services Application 259
Reviewing the Business Application Solution 260
Building an Entity Data Model 261
Building a Domain Service 264
Connecting the Silverlight Client to Your Domain Service 268
Connecting to the Domain Service through XAML 273
Filtering Results 277
Summary 280
OUTOFBROWSER EXPERIENCES 28CHAPTER 9: 1
Creating an Out-of-Browser Application 281
Out-of-Browser Application Features 282
www.it-ebooks.info
xvii
CONTENTS
Configuring an Out-of-Browser Application in Visual Studio 283
Installing an Out-of-Browser Application 287
Uninstalling an Out-of-Browser Application 290
Updating an Out-of-Browser Application 290
Installing Trusted Applications 292
Accessing the File Systems 295
Using COM Automation 295
Support for Window Customization 296
Adding Digital Signatures 299
Installing a Local Silverlight Application 300
Summary 300
NETWORKING APPLICATIONS 30CHAPTER 10: 1
The WebClient Class 302
Using OpenReadAsync() 302
Downloading Files Using WebClient 304
Uploading Files Using WebClient 307
Reusing a Single WebClient Object 310
Cross-Domain Access 311
Silverlight and WCF Duplex Communications 314
Setting Up the Duplex Service 314
Setting Up the Duplex Client 320
Sockets 323
Setting Up the Policy Server 324
Setting Up the Application Sockets Server 328
Setting Up the Sockets Client 332
Summary 336
BUILDING LINE OF BUSINESS APPLICATIONS 33CHAPTER 11: 7
Line of Business Basics 337
Responding to Mouse Actions 338
Enabling Right-Click Support 340
Handling Multi-Touch 342
Drawing with Ink 343
Enabling Clipboard Access 345
Adding Printing Support 347
Supporting Drag-and-Drop 349
Using the Web Browser Control 350
Advanced Scenarios 351
Communicating between Silverlight Applications 351
Integrating with Oce 364
www.it-ebooks.info
xviii
CONTENTS
Globalization and Localization 366
Localizing Your Application 367
Using Resource Files 367
Packing and Deploying 369
Supporting Bidirectional Right-to-Left (RTL) Text 370
Deploying Best Practices 371
Full-Screen Applications 371
Summary 373
APPLICATION ARCHITECTURE 37CHAPTER 12: 5
Understanding Design Patterns 376
Exploring the Model View ViewModel (MVVM) 377
Learning about Inversion of Control/Dependency Injection 390
Exploring the Event Broker Pattern 395
Using Silverlight Frameworks 396
Exploring the Managed Extensibility Framework 396
Exploring PRISM/Composite Application Library 411
Defining Your Data Access Strategy 424
Handling Performance 427
Summary 428
DOM INTERACTION 42CHAPTER 13: 9
Configuring the Silverlight Plug-In 429
windowless 432
splashScreenSource 433
initParams 436
enablehtmlaccess 437
enableAutoZoom 437
enableGPUAcceleration 437
enableNavigation 437
allowHtmlPopupWindow 437
Plug-In API 438
Creating Interaction between Silverlight and JavaScript 438
JavaScript API 439
HTML Bridge 441
Summary 446
SECURING YOUR APPLICATIONS 44CHAPTER 14: 9
Taking Advantage of ASP.NET 450
Forms-Based Authentication 450
www.it-ebooks.info
xix
CONTENTS
Windows-Based Authentication 455
Authenticating Specific Files and Folders 460
Using ASP.NET Application Services 461
Working with Membership on the Server 461
Working with Membership on the Client 468
Working with Role Management on the Server 470
Summary 477
ACCESSING AUDIO AND VIDEO DEVICES 47CHAPTER 15: 9
Configuring Permissions 479
Accessing Audio and Video Devices 481
Capturing Images from a Video Feed 488
Saving Images to the Filesystem 492
Capturing an Audio Stream 494
Summary 495
WORKING WITH FILE I/O 49CHAPTER 16: 7
The OpenFileDialog and SaveFileDialog Classes 497
Classes for Managing the Filesystem 500
.NET Classes That Represent Files and Folders 501
Using the Path Class 504
Using Basic File Objects from Silverlight 504
Moving, Copying, and Deleting Files 514
Extending on the FileProperties Solution 514
Using the Move, Copy, and Delete Methods 515
Reading and Writing Files 517
Reading from a File 518
Writing to a File 521
Using Streams 523
Using Buered Streams 525
Reading and Writing Binary Files Using FileStream 525
Reading and Writing to Text Files 528
Using Isolated Storage Options 532
Reading and Writing from Isolated Storage 532
Understanding Space Constraints 536
Creating Directories in Isolated Storage 537
Deleting Your Store 538
Summary 539
www.it-ebooks.info
xx
CONTENTS
USING GRAPHICS AND VISUALS 54CHAPTER 17: 1
The Basics 541
Working with Rectangles and Borders 542
Applying Rounded Corners 542
Using the Ellipse 545
Using the Path 545
Using Geometries 548
Using Clipping/Masking Elements 550
Expression Blend Shapes 552
Binding to Shape Properties 554
Images and Media 554
Displaying Images 554
Displaying Media 559
Brushes 560
Painting with Solids 560
Painting with Linear Gradients 560
Painting with Radial Gradients 561
Painting with Images 562
Painting with Video 563
Editing Brushes in Expression Blend 564
Creating ImageBrushes 568
Fonts and Font Embedding 570
Eects 572
Applying Eects 572
Using Native Eects 573
Using Custom Eects 575
Transforms 581
Using 2D Transforms 582
Using Perspective 3D 587
Summary 590
WORKING WITH ANIMATIONS IN SILVERLIGHT 59CHAPTER 18: 1
Storyboard Animations 592
Applying Easing Functions 598
Controlling Storyboards Using Behaviors 601
Nesting Storyboards 601
Using Storyboards as Timers 602
Keyframe Animation 603
Rendering CompositionTargets 607
Animating Visibility 608
Animating Sprites 610
Summary 611
www.it-ebooks.info
xxi
CONTENTS
WORKING WITH TEXT 61CHAPTER 19: 3
Displaying and Inputting Text 613
Using the TextBlock Element 614
Using the RichTextBox Control 621
Font Support and Rendering 634
Using Embedded Fonts 636
Creating Font Glyph Subsets 638
Rendering Text 639
Summary 639
MAKING IT RICHER WITH MEDIA 64CHAPTER 20: 1
Supported Formats 641
Unsupported Windows Media Formats 643
H.264 and AAC Support 643
Digital Rights Management 644
Using the MediaElement Control 644
Build Actions and Referencing Media 645
Adding a MediaElement in Blend 649
Sizing Video and Setting the Stretch Behavior 649
Transforming Video 651
Rotating Video in 3D 652
Clipping Video 653
Painting Elements with the VideoBrush 655
Simulating Video Reflections 656
Enabling GPU Hardware Acceleration 657
Audio Settings 658
Buering 658
Detecting Download Progress 660
Detecting Playback Quality 660
Controlling Playback 661
Responding to Video Markers 663
Handling Failed Media 665
Responding to State Changes 666
Media Playlists 667
Server-Side Playlist (SSPL) Files 667
Advanced Stream Redirector (ASX) Files 669
Encoding Media with Expression Encoder 671
Smooth Streaming and IIS 7 678
Summary 679
www.it-ebooks.info
xxii
CONTENTS
STYLING AND THEMES 68CHAPTER 21: 1
Getting Started 682
Defining a Core Terminology 682
Defining the Working Environment: A XAML-Based Approach 682
Defining Local Styling (Inline Styling) 683
Styling with Resources 684
Working with the Style Object 688
Understanding Value Resolution 689
Creating BasedOn Styles 689
Changing the Look of a Control with a Custom ControlTemplate 690
Defining and Using Implicit Styles 706
Defining and Organizing Resources 707
Defining Standalone ResourceDictionaries 708
Loading ResourceDictionaries (via the Merged Dictionaries Collection) 708
Understanding Resource Scope 709
Organizing Resources 710
Naming Resources 711
Using Themes 712
Using Silverlight Toolkit Themes 712
Creating Custom Themes 716
Distributing Your Theme 716
Editing Styles and Templates in Expression Blend 716
Editing the Default Button Style 716
Creating a Custom Button 719
Summary 721
XAML PRIMER 72APPENDIX A: 3
Introducing XAML 723
Silverlight XAML Basics 724
Declaring Objects in XAML 726
Object or Content Element Syntax 726
Attribute Element Syntax 727
Property Element Syntax 727
Setting a Property Using Implicit Collection Syntax 728
Deciding When to Use Attribute or Property Element Syntax
to Set a Property 729
XAML Hierarchy 730
Events and the Silverlight Control 731
Event Handlers and Partial Classes 731
Event Bubbling 734
www.it-ebooks.info
xxiii
CONTENTS
Markup Extensions 736
Binding Markup Extensions 737
StaticResource Markup Extensions 739
Summary 739
TESTING SILVERLIGHT APPLICATIONS 74APPENDIX B: 1
Creating the Sample Application 741
Using the Silverlight Unit Test Framework 743
Using the Selenium Test Framework 748
Automated UI Testing Using White 751
Mocking Frameworks 755
Summary 755
APPENDIX C: BUILDING FACEBOOK APPLICATIONS
WITH SILVERLIGHT 757
Creating a New Application on Facebook 757
Using the Facebook Developer Toolkit 760
Adding the Facebook Connect Components 760
Using an Asynchronous API Request 764
Adding Features from the Facebook API 767
Summary 773
INTEGRATING SILVERLIGHT INTO SHAREPOINT 2010 77APPENDIX D: 5
The Sample Application 775
Using the SharePoint Foundation 2010 Silverlight Object Model 776
Deploying a Silverlight Application into SharePoint 780
Summary 781
SILVERLIGHT CONTROL ASSEMBLIES 78APPENDIX E: 3
INDEX 787
www.it-ebooks.info

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×

×