Suchen und Finden
Service
Illustrated WPF
Daniel Solis
Verlag Apress, 2010
ISBN 9781430219118 , 550 Seiten
Format PDF, OL
Kopierschutz Wasserzeichen
Content at a Glance
5
Table of Contents
6
About the Author
14
Acknowledgments
15
Introduction
16
Audience, Source Code, and Contact Information
16
1 Introduction to WindowsPresentation Foundation
17
What Is Windows Presentation Foundation?
18
The Path to the Screen
19
Games and DirectX
19
Windows Forms
20
Rendering Under WPF
21
Documents and Fonts
22
Graphics and Animation
22
Styles and Control Templates
23
Separating Visual Design from Coding
23
WPF Prefers Vector Graphics
24
Bitmap Images
24
Bitmap Images and Screen Size
25
Vector Graphics
26
System DPI Independence and WPF Units
27
XAML Browser Applications (XBAPs)
29
The Other Parts of .NET
30
Silverlight
31
Summary
32
2 Overview of WPF Programming
33
What Is an API?
34
A Simple WPF Program
35
Creating the Simple Program
37
Just the Facts
38
Step-by-Step
39
The Compilation Process
44
The Application and Window Classes
45
The Window Class
46
The Components of a Visual Window
46
Creating a Window
47
Important Properties of a Window
49
WindowStyle
50
Content
51
Summary
53
3 WPF Architecture and Applications
54
Using Visual Studio to Create a WPF Program
55
Source Code Generated by the Template
59
What Is XAML?
60
Logical Trees and Visual Trees
61
The Compilation Process
62
How the Files Are Used
64
The WPF Architecture
66
More About the Window Class
67
SolidColorBrushes
68
Creating Colors
70
Gradient Brushes
74
Linear Gradient Brushes
75
RadialGradientBrushes
77
The Application Class
78
Handling Application Events
79
Application Lifetime Events
79
UI Elements Contain Content
82
The Class Inheritance Hierarchy
83
Summary
85
4 XAML
86
A Tree of Objects
87
Using XamlPad
88
Creating the UI Structure
89
XAML Trees
91
Object Element Syntax
91
The Syntax of Elements
92
Attribute Syntax
93
Empty Elements
94
More About Object Element Syntax
95
The Default Content Property
96
Type Converters for Attributes
97
Property Element Syntax
98
Attached Property Syntax
99
Reviewing the XAML Syntax Forms
100
Top-Level Elements
100
Code-Behind and Object Names
101
Namespaces
102
The Syntax of Namespaces
103
Using Classes from Other Namespaces
105
Example Using Namespaces
107
Markup Extensions
108
Example Creating a Markup Extension
110
White Space
112
Special Characters
114
Summary
115
5 Layout
116
Layout in WPF
117
Chapter Conventions
118
The Layout Process
119
Setting the Requested Size of Elements
121
Alignment
122
Content Alignment
123
Visibility
124
Padding and Margins
125
Panels
127
The StackPanel
128
The WrapPanel
129
The DockPanel
131
The Grid
134
Items Spanning Cells
137
Sizing Rows and Columns
139
Absolute Sizing
139
Automatic Sizing
141
Proportional Sizing
142
Splitter Bars
144
Shared Size Groups
147
The Canvas
149
Z-Order on a Canvas
151
The UniformGrid
153
Summary
154
6 Content and Controls
155
Liberating Content
156
Source Code Conventions
157
The Image Element
158
Displaying an Image Using Code
159
The ContentControls
161
The Label Control
162
The Button Control
164
The CheckBox and RadioButton Controls
165
Grouping RadioButtons
166
The ScrollViewer
173
The Window Class
167
Window Ownership
168
Modal Dialog Boxes
169
The MessageBox Dialog Box
172
The HeaderedContentControls
174
The GroupBox Element
175
The Expander Control
176
ItemsControl Elements
177
The ListBox Control
178
Checking the Selection
179
Notification of Changed Selection
180
Multiple Selections
181
The ComboBox Control
182
Selecting and Entering Items
183
Summary
184
7 Dependency Properties
185
Properties and a New Paradigm
186
Looking at an Example
188
Determining the Value of a Property
190
The Infrastructure of a Dependency Property
191
Creating a Custom Dependency Property
192
Example: Creating a Dependency Property
198
Attached Properties
201
The Structure of an Attached Property
203
Creating an Attached Property
204
Summary
207
8 Data Binding
208
What Is Data Binding?
209
The Binding Object
211
Binding Direction
213
Triggers
215
Data Converters
217
Multiple Bindings on an Element
219
More Fun with Multiple Bindings
220
Deleting Bindings
222
Binding to Nonelements
225
Data Contexts
227
Bindings and ItemsControls
228
Summary
232
9 Routing Events and Commands
233
What Is an Event?
234
Event Handlers: Syntax and Semantics
236
What Are Routed Events?
237
Handling Routed Events
238
Bubbling Example
239
Checking for Tunneling
241
Commands
243
Built-in Commands and Support
246
The RoutedCommand Class
251
Creating Custom Commands
252
Routing Commands
255
Summary
256
10 Other Controls and Elements
257
The TextBox Control
258
Menus
260
Adorning the MenuItem
262
Other Content As the Menu Header
263
Attaching Commands to Menu Items
264
Context Menus
266
ToolBars
268
StatusBars
270
ToolTips
271
Controls That Work with Ranges
272
The ProgressBar
272
The Slider
275
Summary
277
11 Resources
278
Two Types of Resources
279
The ResourceDictionary
280
StaticResources and DynamicResources
288
Assembly Resources
292
Accessing Assembly Resources from the Code
293
Pack URIs
295
Summary
297
12 Styles
298
What Are Styles?
299
Named Styles
300
Targeted Styles
303
Comparing Named and Targeted Styles
304
EventSetters
305
The Collections in a Style
306
Property Triggers
307
MultiTriggers
308
Other Types of Triggers
309
Summary
310
13 Control Templates
311
Separating Appearance from Behavior
312
Developing a Simple Control Template
314
The ContentPresenter Class
316
Template Binding
318
ControlTemplate Triggers
319
Summary
322
14 Page Navigation Programs
323
Types of Navigation
324
The Components of a Navigation Program
328
Frames
331
Journal Options in Frames
333
Navigating Programmatically
334
Passing Data to a Page
336
Getting Data Back from a Page
339
XAML Browser Applications
343
Creating an XBAP Application
343
Deploying and Running
344
Summary
346
15 More Data Binding
347
Data Templates
348
Views
356
Filtering in a View
357
Sorting in a View
361
Grouping in a View
364
Summary
368
16 Trees, Tabs, and Other Controls
369
The TreeView Control
370
The HierarchicalDataTemplate
374
Using Event Handlers with TreeViews
380
Binding Other Controls to a TreeView
383
The TabControl
386
The Calendar Control
388
The DatePicker Control
391
Summary
397
17 Text and Documents
398
Text in WPF
399
An Overview of Flow Documents
400
The Components of a Flow Document
403
The Hosting Controls
404
The Content of a Flow Document
405
Tables and Lists
411
Embedded Flow Documents
415
The TextBlock Element
416
Summary
419
18 Graphics in WPF
420
Graphics in WPF
421
Transforms
422
The RotateTransform
423
Using LayoutTransform vs. RenderTransform
425
The TranslateTransform
427
The SkewTransform
428
The ScaleTransform
430
BitmapEffects
431
Brushes
433
LinearGradientBrushes
434
Shapes
438
The Geometry Classes
440
The Simple Geometry Classes
441
The PathGeometry Class
443
The LineSegment and the PolyLineSegment
445
The ArcSegment
446
Combining Geometries
448
Path Markup Syntax
450
Filling Geometries
452
Drawings
455
The DrawingImage Class
457
The DrawingBrush Class
458
Summary
460
19 Animation
461
What Is Animation?
462
Animation Object Basics
464
The AnimationClock Class
468
Storyboards
470
Storyboards in Markup
474
Other Variations on Animation
476
Keyframe Animations
477
Linear Keyframe Animation
478
Spline Interpolation Animations
481
Discrete Keyframe Animation
483
Path Animations
484
Summary
486
20 Audio and Video
487
Overview of Audio
488
SystemSounds
488
SoundPlayer
489
SoundPlayerAction
490
MediaPlayer
491
MediaElement
494
Video
499
Summary
501
Index
502