Now more than ever, Windows applications have to work well and look good. Windows Presentation Foundation (WPF), Microsoft's new user interface framework, gives you the ability to create stunning graphics, rich interactions, and highly-usable Windows applications. WPF is the API beneath Windows Vista interfaces, and it's also available for older versions of Windows. Up to this point, it has only been possible to build WPF applications manually, mainly by hand-coding in XAML-WPF's declarative XML-based markup language. The soon-to-be-released Visual Studio 2008 provides the full set of developer tools you need to take advantage of this exciting technology. The combination of WPF and Visual Studio 2008 represents the start of the next generation of Windows applications. Hand-coding XAML is fine if you're an early adopter, but to put WPF into production, you need to master the tools and application styles you'll use in your day job. WPF In Action focuses on WPF development using Visual Studio 2008 and other available tools.. The book starts with thorough coverage of the basics-layouts, styles, resources, and themes. It then takes you through several real-world scenarios, exploring common challenges and application-types. You'll build several sample applications, ranging from a simple calculator to a typical line-of-business application. Along the way, you'll add graphical elements, animation, and support for printing, accessibility, and other standard functionality. Written in a witty, engaging style, WPF In Action can be read cover-to-cover or used to reference specific problems and issues. The approach is practical and always focused on how you'll use WPF in real development scenarios. You'll learn how to handle the many new issues presented by the extreme flexibility of WPF. The authors also provide numerous tips and suggestions for how to work efficiently.
Author(s): Arlen Feldman, Maxx Daymon
Edition: 1
Publisher: Manning Publications
Year: 2008
Language: English
Pages: 650
preface......Page 18
acknowledgments......Page 20
Roadmap......Page 22
Code......Page 23
About the authors......Page 24
About the title......Page 25
about the cover illustration......Page 26
Part 1 - Past, present, and future......Page 27
The road to Avalon (WPF)......Page 29
1.1 The past and the present......Page 30
1.1.1 Why Windows drawing is the way it is......Page 31
1.1.2 How we currently create Windows UIs......Page 33
1.1.3 Why the web is the way it is......Page 35
1.1.4 How UI is created on the web......Page 36
1.2 Why Avalon/WPF......Page 37
1.2.1 Taking advantage of modern hardware......Page 38
1.2.2 Using modern software design......Page 39
1.2.3 Separating presentation logic from presentation......Page 40
1.2.4 Making it simpler to code GUIs......Page 41
1.3.1 Defining WPF UI with XAML......Page 42
1.3.2 Defining WPF UI through code......Page 43
1.3.3 Defining WPF UI with tools......Page 44
1.3.5 Pixels versus vectors......Page 45
1.4 Summary......Page 46
Getting started with WPF and Visual Studio 2008......Page 48
2.1 Your grandpa’s Hello, World!......Page 49
2.1.1 Adding a button and button-handler to the window......Page 51
2.1.3 The TextBlock control......Page 53
2.2.1 Defining application startup in XAML......Page 56
2.2.2 Why define the application in XAML?......Page 57
2.3 A tour of WPF in Visual Studio 2008......Page 60
2.3.1 The XAML designer......Page 61
2.3.2 The Properties grid......Page 64
2.3.4 The Document Outline......Page 65
2.4 Summary......Page 66
WPF from 723 feet......Page 67
3.1.1 Red bits and green bits......Page 68
3.1.2 Silverlight......Page 69
3.2.1 Base services......Page 70
3.2.2 Media services......Page 77
3.2.3 User interface services......Page 81
3.2.4 Document services......Page 82
3.3 Necessary and useful tools......Page 84
3.3.1 Microsoft Expression family......Page 85
3.3.3 Other tools......Page 86
3.4 Summary......Page 87
Part 2 - The basics......Page 89
Working with layouts......Page 91
4.1 The idea behind layout panels......Page 92
4.2 The Canvas layout......Page 94
4.2.2 Adding a Canvas to an existing layout......Page 95
4.2.3 Using attached properties......Page 98
4.2.4 Setting up a Canvas programmatically......Page 99
4.3 The StackPanel layout......Page 102
4.3.1 Adding scrolling support......Page 106
4.3.2 The Expander control......Page 107
4.4 The DockPanel layout......Page 109
4.4.1 Defining a DockPanel in XAML......Page 110
4.4.2 Setting up a DockPanel programmatically......Page 111
4.5 The WrapPanel layout......Page 112
4.6 Other layout options......Page 114
4.6.2 The FlowDocument......Page 115
4.7 Summary......Page 119
The Grid panel......Page 120
5.1 Getting started with the Grid layout panel......Page 121
5.1.1 Modifying the Grid......Page 122
5.1.2 Grid specific properties......Page 126
5.2.1 Planning the calculator......Page 127
5.2.2 Laying out the calculator......Page 128
5.2.3 Tweaking appearance......Page 130
5.3 The Grid and localization......Page 133
5.4 UniformGrid......Page 135
5.5.1 Handling operations......Page 136
5.5.2 Genericizing the handlers......Page 140
5.6 Summary......Page 143
Resources, styles, control templates, and themes......Page 145
6.1 Resources......Page 146
6.1.1 Using standalone resource dictionaries......Page 148
6.1.2 Using resources from code......Page 150
6.1.3 Dynamic resources......Page 151
6.2 Styles......Page 157
6.2.1 Styles based on other styles......Page 159
6.2.2 Implicitly applying styles......Page 161
6.3 Control templates......Page 162
6.3.2 ContentPresenters......Page 163
6.3.3 Template binding......Page 164
6.3.4 Triggers......Page 165
6.4 Themes......Page 166
6.4.1 Using a specific theme......Page 168
6.4.2 Changing themes from code......Page 171
6.5 Summary......Page 172
Events......Page 173
7.1 Routed events......Page 174
7.1.1 Bubbling events......Page 175
7.1.2 Tunneling events......Page 177
7.2 Events from code......Page 180
7.2.1 handledEventsToo......Page 181
7.3 Summary......Page 182
Oooh, shiny!......Page 183
8.1 Glass buttons......Page 184
8.1.2 Adding glow when over buttons......Page 188
8.1.3 Handling the button click......Page 190
8.2.1 Animating button glow......Page 191
8.2.2 Animating a color......Page 194
8.3 Reflections......Page 195
8.4 Transforms......Page 199
8.5 Summary......Page 200
Part 3 - Application development......Page 203
Laying out a more complex application......Page 205
9.1 Creating the Desktop Wiki Project......Page 207
9.2 Nesting layouts......Page 208
9.2.1 Preparing the layout for menus and toolbars......Page 209
9.2.2 Adding menubars, statusbars, and toolbars…......Page 210
9.3 Nested layouts......Page 212
9.3.1 Adding the first Grid......Page 213
9.3.2 Adding the second Grid......Page 214
9.3.3 Using a StackPanel and Expander as navigation aids......Page 215
9.4 Summary......Page 216
Commands......Page 217
10.1.1 Windows Forms and simple event handlers......Page 218
10.1.2 Son of MFC......Page 219
10.2.1 The Command pattern......Page 220
10.2.2 WPF commands......Page 221
10.3 Using the built-in system commands......Page 222
10.3.1 ApplicationCommands......Page 223
10.3.3 EditingCommands......Page 224
10.4.1 Handling a built-in command......Page 226
10.4.2 Creating a custom command......Page 227
10.4.3 Shortcuts and gestures......Page 228
10.5 Command routing......Page 229
10.6.1 Implementing a RoutedUICommand......Page 230
10.6.2 Adding a CommandBinding......Page 232
10.7 Summary......Page 234
Data binding with WPF......Page 235
11.1 WPF data binding......Page 236
11.2.1 Binding Data with XAML......Page 238
11.2.2 Binding in code......Page 243
11.2.3 Binding notation and options......Page 245
11.3 Binding to XML......Page 249
11.3.1 Creating the CVE Viewer application......Page 251
11.3.2 Binding controls to XML......Page 253
11.3.3 XPath binding notation......Page 254
11.3.4 Path versus XPath......Page 255
11.3.5 Understanding and using DataContexts......Page 256
11.3.6 Master-Detail Binding......Page 259
11.4 Binding to ADO.NET database objects......Page 260
11.4.2 Creating the simple DAL......Page 262
11.4.3 Laying out the UI and creating data bindings......Page 264
11.5.1 Creating a WikiPage business object......Page 268
11.5.2 ObservableCollection......Page 269
11.5.3 Create a model façade......Page 270
11.5.4 Wiring business objects to presentation objects......Page 272
11.6 Binding to LINQ data......Page 276
11.7 Summary......Page 278
Advanced data templates and binding......Page 279
12.1 Data converters......Page 280
12.1.1 Formatting bound data with StringFormat......Page 281
12.1.2 A number to formatted string data converter......Page 285
12.1.3 Converter parameters......Page 287
12.2 DataTriggers......Page 289
12.3.1 Sorting with CollectionViewSource......Page 292
12.3.2 Programatically sorting with CollectionViewSource......Page 294
12.3.3 Filtering with CollectionViewSource......Page 296
12.4.1 A more involved template......Page 299
12.4.2 Conditionally using a template......Page 301
12.4.3 Templates based on type......Page 303
12.5.1 The ExceptionValidationRule......Page 304
12.5.2 Custom ErrorTemplates......Page 306
12.5.3 Custom validation rules......Page 308
12.6 Model-View-ViewModel......Page 309
12.7.1 Hierarchical binding......Page 311
12.7.2 MultiBinding......Page 315
12.7.3 PriorityBinding......Page 321
12.8 Summary......Page 324
Custom controls......Page 325
13.1.1 Building a LinkLabel control......Page 327
13.1.2 Testing the LinkLabel UserControl......Page 330
13.2 Building custom controls......Page 332
13.2.1 Building a control library......Page 333
13.2.2 Create the new custom control......Page 334
13.2.3 Create the default template for the control......Page 336
13.2.4 Testing the control......Page 338
13.2.5 Customizing a custom control with a template......Page 339
13.3 Summary......Page 340
Drawing......Page 341
14.1.1 Shapes in XAML......Page 343
14.1.2 Stupid shape tricks......Page 347
14.2.1 Building the GraphHolder control......Page 349
14.2.2 Graphing using shapes......Page 353
14.2.3 Catching clicks......Page 357
14.3 Drawing with direct rendering......Page 358
14.3.1 Recreating the graph control......Page 359
14.4 Drawing with Visuals......Page 364
14.4.1 Control for display Visuals......Page 365
14.4.2 Hit testing with Visuals......Page 368
14.4.3 Adding labels to our graph......Page 370
14.5 Drawings and Geometries......Page 371
14.5.1 GeometryDrawing......Page 374
14.5.2 Using Drawings......Page 375
14.6 Summary......Page 377
Drawing in 3D......Page 378
15.1 Lights, camera…......Page 379
15.1.1 Models......Page 380
15.1.2 Lights......Page 383
15.1.3 Cameras......Page 384
15.2 Graphing in 3D......Page 385
15.3 3D Transforms......Page 391
15.3.2 A 3D Transform in code......Page 392
15.4 Summary......Page 395
Part 4 - The last mile......Page 397
Building a navigation application......Page 399
16.1 When and where to use navigation applications......Page 400
16.2 Creating a basic navigation application......Page 401
16.2.1 Adding some navigation......Page 404
16.2.2 Implementing dictionary lookup......Page 405
16.2.3 Navigating programmatically......Page 407
16.3.1 Creating a Page function......Page 410
16.3.2 Calling a page function......Page 412
16.4 Summary......Page 415
WPF and browsers: XBAP, ClickOnce, and Silverlight......Page 416
17.1 Building an XBAP......Page 417
17.1.1 XBAP security......Page 420
17.1.2 Deploying an XBAP......Page 422
17.1.3 When to use XBAP......Page 425
17.2 Using ClickOnce......Page 426
17.2.1 Deploying a WPF application via ClickOnce......Page 427
17.2.2 When to use ClickOnce......Page 428
17.3 Using Silverlight......Page 429
17.4 Summary......Page 431
Printing, documents, and XPS......Page 432
18.1 Printing flow documents......Page 433
18.1.1 Setting up to print......Page 434
18.1.2 Customizing the output......Page 437
18.1.3 Printing asynchronously......Page 439
18.2 Printing FixedDocuments......Page 441
18.2.1 Adding some FlowDocument content to our FixedDocument......Page 443
18.2.2 Matching resolution......Page 446
18.2.3 Printing Visuals......Page 447
18.3.1 Saving an XPS document to a file......Page 448
18.3.2 The problem with images…......Page 450
18.4 Summary......Page 452
Transition effects......Page 453
19.1.1 The DictionaryLookup class......Page 454
19.1.2 Working with the Application object......Page 457
19.1.3 Our WorldListView user control......Page 458
19.1.4 Populating the country list......Page 459
19.2 Adding a simple transition......Page 462
19.3.1 Creating the transition control......Page 465
19.3.2 Using the transition control......Page 468
19.3.3 Defining a ControlTemplate for our control......Page 469
19.4 Adding some interesting transition effects......Page 471
19.4.1 The fade effect......Page 472
19.4.2 Wipe effect......Page 474
19.4.3 Adding a selector for effects......Page 479
19.5 Summary......Page 480
Interoperability......Page 483
20.1.1 Using the Windows Forms DateTimePicker in WPF......Page 484
20.1.2 Enabling Windows themes for Windows Forms control......Page 487
20.1.3 What you can’t do with embedded Windows Forms controls......Page 488
20.1.4 Using your own Windows Forms controls......Page 489
20.1.5 Popping up Windows Forms dialogs......Page 490
20.2.1 Embedding ActiveX controls in WPF......Page 492
20.2.2 Embedding C++ controls in WPF......Page 494
20.3.1 Using a WPF control inside of Windows Forms......Page 495
20.3.2 Popping up WPF dialogs......Page 498
20.4 Summary......Page 499
Threading......Page 500
21.1 Moving slow work into a background thread......Page 502
21.2 Asynchronous calls......Page 505
21.3 Timers......Page 506
21.4 Summary......Page 507
C......Page 509
D......Page 510
H......Page 511
M......Page 512
R......Page 513
T......Page 514
X......Page 515
Z......Page 516