Suchen und Finden
Contents at a Glance
5
Table of Contents
6
About the Authors
27
About the Technical Reviewers
28
Acknowledgments
29
Introduction
30
Who This Book Is For
30
How This Book Is Structured
31
Prerequisites
31
Downloading the Code
31
Contacting the Authors
31
CHAPTER 1 Quick Tour of Silverlight 4 Development
32
Getting Up to Speed with Silverlight
32
Silverlight 3 Highlights
34
Major Media Enhancements
35
Enhanced User Experience Rendering Capabilities
35
Rich Internet Applications and Line-of-Business Enhancements
35
WCF RIA Services Data Support Improvements
36
Browser Support
36
Out-of-Browser Capabilities
37
Silverlight 4
37
Business Application Development
37
Developer Tools
38
Interactive User Experiences
38
Out-of-Browser Programming Model
39
Silverlight and Visual Studio 2010
39
1-1. Setting Up the Silverlight 4 Environment
40
Problem
40
Solution
41
How It Works
41
1-2. Installing Additional Silverlight-Related Services and Controls
41
Problem
41
Solution
42
How It Works
42
1-3. Understanding the Structure of a Silverlight Solution
42
Problem
42
Solution
42
How It Works
43
The Code
44
1-4. Understanding the Developer/Designer Workflow
52
Problem
52
Solution
52
How It Works
53
The Tools
53
The Process
54
1-5. Understanding the Basics of Expression Blend 4
56
Problem
56
Solution
56
How It Works
56
The Code
58
1-6. Accessing Source Control
63
Problem
63
Solution
63
How It Works
63
1-7. Running Silverlight 4 on a Mac
64
Problem
64
Solution
64
How It Works
64
1-8. Running Silverlight on Linux
64
Problem
64
Solution
65
How It Works
65
CHAPTER 2 Application Design and Programming Model
66
The Mechanics of Silverlight Applications
66
2-1. Leverage and Locate Controls and Classes
68
Problem
68
Solution
68
How It Works
68
Add a Custom Control
68
Find a Control
68
2-2. Dynamically Loading XAML
79
Problem
79
Solution
79
How It Works
79
The Code
79
2-3. Persisting Data on the Client
85
Problem
85
Solution
85
How It Works
85
The Code
87
2-4. Opening a Local File from a Silverlight Application
92
Problem
92
Solution
92
How It Works
92
The Code
93
2-5. Accessing XML Data
96
Problem
96
Solution
96
How It Works
97
The Code
97
2-6. Managing Unhandled Exceptions
101
Problem
101
Solution
102
How It Works
102
2-7. Executing Work on a Background Thread with Updates
102
Problem
102
Solution
103
How It Works
103
The Code
104
2-8. Updating the UI from a Background Thread
112
Problem
112
Solution
112
How It Works
113
The Code
114
2-9. Managing XAML Resources
117
Problem
117
Solution
117
How It Works
117
The Code
118
2-10. Managing Embedded Resources
122
Problem
122
Solution
122
How It Works
122
The Code
122
2-11. Creating Silverlight Using Ruby, Python, or JScript
127
Problem
127
Solution
127
How It Works
127
The Code
128
2-12. Creating Application Services
131
Problem
131
Solution
131
How It Works
131
The Code
132
2-13. Managing Resources in Large Projects
136
Problem
136
Solution
136
How It Works
137
The Code
137
2-14. Save a File Anywhere on the User’s System
139
Problem
139
Solution
140
How It Works
140
The Code
140
CHAPTER 3 Developing User Experiences
142
3-1. Importing Art from Expression Design
143
Problem
143
Solution
143
How It Works
143
3-2. Working with Color and Gradients in Blend
146
Problem
146
Solution
146
How It Works
146
The Code
149
3-3. Positioning UI Elements
153
Problem
153
Solution
153
How It Works
153
Canvas
154
Grid
155
The Code
156
Code for Canvas
156
Code for StackPanel
158
Code for the Grid
159
3-4. Drawing with Shapes, Paths, and Geometries
162
Problem
162
Solution
163
How It Works
163
Drawing with Shapes
163
Drawing with Path Objects
168
Drawing with Geometries
169
The Code
170
Drawing with Paths
170
Drawing with Geometries
175
3-5. Providing Scrollable Content
180
Problem
180
Solution
180
How It Works
181
The Code
181
3-6. Applying a Border to Elements
183
Problem
183
Solution
183
How It Works
183
The Code
186
3-7. Using Simple Animations with Objects
188
Problem
188
Solution
188
How It Works
188
The Code
189
3-8. Animating UI Elements with Keyframes
195
Problem
195
Solution
195
How It Works
195
The Code
198
3-9. Transforming an Object
200
Problem
200
Solution
201
How It Works
201
The Code
202
3-10. Creating a Simple Cartoon Scene
206
Problem
206
Solution
206
How It Works
206
The Code
206
3-11. Handling Keyboard Input
211
Problem
211
Solution
211
How It Works
211
The Code
212
3-12. Working with Ink
215
Problem
215
Solution
215
How It Works
216
The Code
216
3-13. Adding 3-D Effects to UI Elements
222
Problem
222
Solution
222
How It Works
222
The Code
223
3-14. Dynamically Creating Bitmaps
229
Problem
229
Solution
229
How It Works
229
The Code
230
3-15. Improving Graphic Animation and Video Performance
236
Problem
236
Solution
236
How It Works
236
The Code
237
3-16. Improve Animation with Custom Easing Functions
240
Problem
240
Solution
240
How It Works
240
The Code
241
3-17. Adding Pixel Shader Visual Effects
247
Problem
247
Solution
247
How It Works
247
The Code
248
3-18. Create and Work with Design-Time Data in Expression Blend
252
Problem
252
Solution
252
How It Works
252
The Code
255
3-19. Reuse Application Interactivity with Behaviors
262
Problem
262
Solution
262
How It Works
262
The Code
263
3-20. Customizing the Right-Click Context Menu
264
Problem
264
How it Works
265
The Code
265
3-21. Accessing the Clipboard
269
Problem
269
How it Works
269
The Code
270
3-22. Using Right-to-Left Text
272
Problem
272
How it Works
273
The Code
273
3-23. Prototype Application Design
274
Problem
274
Solution
275
How It Works
275
The Code
275
CHAPTER 4 Data Binding
277
4-1. Binding Application Data to the UI
277
Problem
277
Solution
277
How It Works
277
Binding Expression
277
Dependency Properties
278
Associating the Data Source
278
The Code
279
4-2. Binding Using a DataTemplate
285
Problem
285
Solution
285
How It Works
285
Declaring a DataTemplate
285
Using a DataTemplate
287
The Code
287
4-3. Receiving Change Notifications for Bound Data
293
Problem
293
Solution
293
How It Works
293
Change Notification for Noncollection Types
293
Change Notification for Collection Types
294
The Code
295
4-4. Converting Values During Data Binding
310
Problem
310
Solution
310
How It Works
310
Implementing Value Conversion
311
The Code
312
4-5. Binding Across Elements
323
Problem
323
Solution
323
How It Works
323
Binding to Another Element
323
Binding to Self
324
Binding to the TemplatedParent
324
The Code
325
4-6. Validating Input for Bound Data
331
Problem
331
Solution
331
How It Works
331
Validation Error Notification
331
Getting Error Information
331
Getting a Validation Error Summary
332
The Code
332
4-7. Controlling Updates
346
Problem
346
Solution
346
How It Works
346
The Code
347
4-8. Providing reasonable defaults for bound data
356
Problem
356
Solution
356
How It Works
356
Null Value Replacement
357
Fallback value
357
String Formatting
358
The Code
358
CHAPTER 5 Controls
362
A Word About the Samples
363
5-1. Customizing a Control’s Basic Appearance
363
Problem
363
Solution
363
How It Works
363
Style Scoping
364
The Code
365
5-2. Replacing the Default UI of a Control
367
Problem
367
Solution
367
How It Works
367
Control Template Syntax
367
Setting the Template
367
Using Expression Blend to Design a Template
368
Template Bindings
370
Content Model and Presenter Controls
371
Visual State Management
373
The Code
377
5-3. Customizing the Default ListBoxItem UI
383
Problem
383
Solution
383
How It Works
383
The Code
384
5-4. Displaying Information in a Pop-up
392
Problem
392
Solution
392
How It Works
392
Creating and Initializing the Pop-up
392
Positioning the Pop-up
392
Creating Pop-up Content
394
The Code
394
5-5. Displaying Row Details in a DataGrid
404
Problem
404
Solution
404
How It Works
404
The Code
404
5-6. Applying Custom Templates to a DataGrid Cell
414
Problem
414
Solution
414
How It Works
414
The Code
414
5-7. Creating Custom Column Types for a DataGrid
420
Problem
420
Solution
420
How It Works
420
The GenerateElement() Method
421
The GenerateEditingElement() Method
421
The PrepareCellForEdit() Method
422
The CancelCellEdit() Method
422
The Code
422
5-8. Creating a Composite User Control
427
Problem
427
Solution
427
How It Works
427
User Control Structure
428
XAML Loading
429
Dependency Properties
431
The Code
432
5-9. Creating a Custom Layout Container
441
Problem
441
Solution
442
How It Works
442
Motivation and Mechanics
442
The MeasureOverride() Method
442
The ArrangeOverride() Method
443
The Code
443
Using the WrapPanel
449
5-10. Creating a Custom Control
454
Problem
454
Solution
455
How It Works
455
Custom Control Structure
455
TemplateBinding vs. RelativeSource Binding to TemplatedParent
457
The Code
458
Using the Control
463
5-11. Defining a Custom Visual State
471
Problem
471
Solution
471
How It Works
471
The Code
472
5-12. Controlling ScrollViewer Scroll Behavior
483
Problem
483
Solution
483
How It Works
483
The VisualTreeHelper class
483
The Code
484
5-13. Customizing the Binding Validation User Interface
492
Problem
492
Solution
493
How It Works
493
Validation Error Tooltip
493
The ValidationSummary Control
497
The Code
498
5-14. Control Behavior in Expression Blend
508
Problem
508
Solution
508
How It Works
508
Property Attributes
508
Designer-Unsafe Code
510
Including Sample Data
511
The Code
512
5.15 Enhancing the Design Experience with Behaviors and Triggers
515
Problem
515
Solution
515
How It Works
515
Behavior
515
Triggers and Actions
516
The Code
517
CHAPTER 6 Browser Integration
524
6-1. Host Silverlight on Any Technology
524
Problem
524
Solution
525
How It Works
525
The Code
527
6-2. Setting Focus for Keyboard Input
529
Problem
529
Solution
529
How It Works
530
The Code
530
6-3. Implementing a Full-Screen UI
535
Problem
535
Solution
535
How It Works
535
The Code
537
6-4. Calling a JavaScript Method from Managed Code
544
Problem
544
Solution
544
How It Works
544
The Code
546
6-5. Calling a Managed Code Method from JavaScript
552
Problem
552
Solution
552
How It Works
553
The Code
554
6-6. Exchanging Data Among Multiple Plug-ins
561
Problem
561
Solution
561
How It Works
561
The Code
562
6-7. Layering HTML over the Silverlight Plug-in
567
Problem
567
Solution
567
How It Works
568
The Code
568
6-8. Hosting HTML in a Silverlight Application
570
Problem
570
Solution
570
How It Works
571
The Code
571
6-9. Painting a Silverlight Element with HTML
573
Problem
573
Solution
573
How It Works
573
The Code
573
6-10. Taking Advantage of the Navigation Framework
575
Problem
575
Solution
575
How It Works
575
The Code
578
6-11. Embedding Silverlight within a Windows Gadget
584
Problem
584
Solution
584
How It Works
584
The Code
589
6-12. Embedding Silverlight in an Internet Explorer 8 Web Slice
600
Problem
600
Solution
600
How It Works
600
The Code
600
CHAPTER 7 Networking and Web Service Integration
606
A Quick Word about the Samples
607
7-1. Consuming a WCF Service
608
Problem
608
Solution
608
How It Works
608
Invoking a Service Operation
610
Configuring a WCF Service for Silverlight
611
The Code
612
7-2. Exchanging XML Messages over HTTP
629
Problem
629
Solution
629
How It Works
629
Using HttpWebRequest/HttpWebResponse in Silverlight
630
Configuring WCF to Use Non-SOAP Endpoints
631
The Code
631
7-3. Using JSON Serialization over HTTP
642
Problem
642
Solution
642
How It Works
642
JSON
642
Using the DataContractJsonSerializer Type
643
Configuring WCF to Use JSON
643
The Code
644
7-4. Accessing Resources over HTTP
647
Problem
647
Solution
647
How It Works
647
Downloading/Uploading Resources
647
Reading/Writing Remote Streams
648
WebClient and HTTP Endpoints
648
Canceling Long-Running Operations
648
The Code
648
7-5. Using Sockets to Communicate over TCP
672
Problem
672
Solution
672
How It Works
672
The Sockets API in Silverlight
673
Cross-Domain Policy and Port Requirements
675
The Code
675
Running the Sample Code
675
The Client
676
The Chat Server
695
The Policy Server
702
7-6. Enabling Cross-Domain Access
705
Problem
705
Solution
705
How It Works
705
The Code
707
7-7. Exchanging Data between Silverlight Applications
709
Problem
709
Solution
709
How It Works
709
Receiver Registration
709
Receiving Messages
710
Sending Messages
711
Request-Response
712
The Code
712
CHAPTER 8 Building Out Of Browser Silverlight Applications
728
8-1. Building a Silverlight application to run outside the browser
728
Problem
728
Solution
729
How It Works
729
Preparing the Application
729
Installing the Application
731
Customizing the Installation Flow
732
Sensing Network Availability
734
Updating Locally Installed Applications
734
The Code
735
8-2. Controlling the Application Window
751
Problem
751
Solution
751
How It Works
751
Window Attributes
751
Resizing and moving a Window
753
The Code
753
8-3. Using COM Interoperability and File System Access
759
Problem
759
Solution
760
How It Works
760
COM Interoperability
760
Instantiating a COM object
760
Handling a COM event
761
File System Access
762
The Code
762
Windows Image Acquisition
763
The Application Code
766
Saving Images to the disk
772
Taskbar Notification
772
CHAPTER 9 Building LOB Applications
774
Silverlight LOB Enhancements
774
Data Access Enhancements
774
WCF Data Services
775
WCF RIA Services
775
9-1. Accessing RESTful Data using OData
775
Problem
775
Solution
775
How It Works
776
The Code
776
9-2. Using Visual Studio 2010 WCF Data Services Tooling
779
Problem
779
Solution
779
How It Works
779
The Code
779
9-3. Implementing CRUD Operations in WCF Data Services
785
Problem
785
Solution
785
How It Works
786
The Code
786
9-4. Using Visual Studio 2010 WCF RIA Data Services Tooling
789
Problem
789
Solution
789
How It Works
789
The Code
790
9-5. Taking Advantage of the Business Application Template
797
Problem
797
Solution
797
How It Works
797
The Code
797
9-6. Databinding in XAML
799
Problem
799
Solution
799
How It Works
800
The Code
800
9-7. Navigating RIA LOB Data
802
Problem
802
Solution
802
How It Works
802
The Code
802
9-8. Implementing CRUD Operations in RIA Services
804
Problem
804
Solution
804
How It Works
805
The Code
805
9-9. Data Validation through Data Annotation
808
Problem
808
Solution
808
How It Works
808
The Code
809
9-10. Printing in a Silverlight LOB Application
812
Problem
812
Solution
812
How It Works
812
The Code
812
CHAPTER 10 Integrating Rich Media
815
10-1. Adding Video to a Page
815
Problem
815
Solution
816
How It Works
816
Using MediaElement
816
VideoBrush
816
10-2. Creating a Complete Video Player
820
Problem
820
Solution
820
How It Works
820
Acquiring Media
820
Controlling Media Play
821
MediaElement States
821
Seeking Within the Media
822
Volume
823
The Code
823
Installing the Sample Code
823
The Player Code
824
The MediaSlider Custom Control
837
The MediaButtonsPanel Custom Control
847
10-3. Adding Streaming Media Support
851
Problem
851
Solution
852
How It Works
852
Network Considerations
852
Windows Media Services
853
Setting Up WMS 2008
853
Setting Up Publishing Points
855
The Code
857
Changes to the Player
858
10-4. Using Playlists to Package Media
892
Problem
892
Solution
892
How It Works
892
Server-Side Playlists
892
Client-Side Playlists
894
The Code
895
10-5. Using Markers to Display Timed Content
898
Problem
898
Solution
898
How It Works
898
Encoding Markers Using Expression Encoder 3
898
MediaElement and Markers
899
The Code
900
10-6. Displaying and Seeking Using SMPTE Timecodes
914
Problem
914
Solution
915
How It Works
915
Frame Rate
915
Timecodes
915
Timecodes and Silverlight
916
The Code
916
10-7. Building a Managed Decoder for Silverlight
928
Problem
928
Solution
928
How It Works
928
Silverlight, Containers, and Codecs
929
MediaStreamSource
929
Initializing the Media Stream
930
Sampling
932
Stream Switching
933
Seeking
934
The Code
934
The Recorder
934
The Custom MediaStreamSource
942
10-8. Using a WebCam
952
Problem
952
Solution
953
How It Works
953
Webcam and Microphone as devices
953
Video and Audio Format Choices
953
Starting Device Capture
954
Capturing a still image
954
The Code
955
10-9. Processing Raw WebCam Output
960
Problem
960
Solution
960
How It Works
960
VideoSink and AudioSink
960
The Code
961
CHAPTER 11 Integrating Microsoft IIS Smooth Streaming
976
11-1. Setting up Smooth Streaming
977
Problem
977
Solution
977
How It Works
977
IIS Media Services
977
Setting Up IIS7
981
The Silverlight Client/Smooth Streaming Server Data Exchange
982
Testing the Smooth Streaming Presentation
983
The Code
984
11-2. Using the SmoothStreamingMediaElement
984
Problem
984
Solution
985
How It Works
985
The IIS Smooth Streaming Player Development Kit
985
The Code
985
11-3. Adding Metadata Streams
990
Problem
990
Solution
990
How It Works
990
Streams and Tracks
991
The Code
993
Injecting the Metadata and Content
993
Using Metadata at Playback
996
11-4. Merging Data from External Manifests
1001
Problem
1001
Solution
1001
How It Works
1001
The Code
1002
Creating the External Manifests
1002
Merging the Manifests at Runtime
1003
11-5. Scheduling Additional Clips
1004
Problem
1004
Solution
1004
How It Works
1004
The Code
1005
11-6. Varying Playback Speeds
1008
Problem
1008
Solution
1009
How It Works
1009
The Code
1009
11-7. Combining Streams Using Composite Manifests
1009
Problem
1009
Solution
1010
How It Works
1010
The Code
1012
Index
1013
Alle Preise verstehen sich inklusive der gesetzlichen MwSt.