WPF in Action with Visual Studio 2008
Covers Visual Studio 2008 Service Pack 1 and .NET 3.5 Service Pack 1!
Arlen Feldman and Maxx Daymon
  • November 2008
  • ISBN 9781933988221
  • 520 pages
  • printed in black & white

... essential for anyone learning WPF.

Curt Christianson, DF-Software

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 with Visual Studio 2008 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.

Table of Contents show full



about this book

about the cover illustration

Part 1 Past, present, and future

1. The road to Avalon (WPF)

1.1. The past and the present

1.1.1. Why Windows drawing is the way it is

1.1.2. How we currently create Windows UIs

1.1.3. Why the web is the way it is

1.1.4. How UI is created on the web

1.2. Why Avalon/WPF

1.2.1. Taking advantage of modern hardware

1.2.2. Using modern software design

1.2.3. Separating presentation logic from presentation

1.2.4. Making it simpler to code GUIs

1.3. Creating UI using WPF

1.3.1. Defining WPF UI with XAML

1.3.2. Defining WPF UI through code

1.3.3. Defining WPF UI with tools

1.3.4. Who does the drawing

1.3.5. Pixels versus vectors

1.4. Summary

2. Getting started with WPF and Visual Studio 2008

2.1. Your grandpa’s Hello, World!

2.1.1. Adding a button and button-handler to the window

2.1.2. Running Hello, World!

2.1.3. The TextBlock control

2.2. The application definition

2.2.1. Defining application startup in XAML

2.2.2. Why define the application in XAML?

2.3. A tour of WPF in Visual Studio 2008

2.3.1. The XAML designer

2.3.2. The Properties grid

2.3.3. Selection controls in Visual Studio

2.3.4. The Document Outline

2.4. Summary

3. WPF from 723 feet

3.1. Where does WPF fit in Windows?

3.1.1. Red bits and green bits

3.1.2. Silverlight

3.2. Framework services

3.2.1. Base services

3.2.2. Media services

3.2.3. User interface services

3.2.4. Document services

3.3. Necessary and useful tools

3.3.1. Microsoft Expression family

3.3.2. Visual Studio

3.3.3. Other tools

3.4. Summary

Part 2 The basics

4. Working with layouts

4.1. The idea behind layout panels

4.2. The Canvas layout

4.2.1. Converting a Grid layout to a Canvas layout by modifying the XAML

4.2.2. Adding a Canvas to an existing layout

4.2.3. Using attached properties

4.2.4. Setting up a Canvas programmatically

4.3. The StackPanel layout

4.3.1. Adding scrolling support

4.3.2. The Expander control

4.4. The DockPanel layout

4.4.1. Defining a DockPanel in XAML

4.4.2. Setting up a DockPanel programmatically

4.5. The WrapPanel layout

4.6. Other layout options

4.6.1. Specialized layout panels

4.6.2. The FlowDocument

4.7. Summary

5. The Grid panel

5.1. Getting started with the Grid layout panel

5.1.1. Modifying the Grid

5.1.2. Grid specific properties

5.2. Using the Grid layout to build a calculator UI

5.2.1. Planning the calculator

5.2.2. Laying out the calculator

5.2.3. Tweaking appearance

5.3. The Grid and localization

5.4. UniformGrid

5.5. Making the calculator work

5.5.1. Handling operations

5.5.2. Genericizing the handlers

5.6. Summary

6. Resources, styles, control templates, and themes

6.1. Resources

6.1.1. Using standalone resource dictionaries

6.1.2. Using resources from code

6.1.3. Dynamic resources

6.2. Styles

6.2.1. Styles based on other styles

6.2.2. Implicitly applying styles

6.3. Control templates

6.3.1. Creating a control template

6.3.2. ContentPresenters

6.3.3. Template binding

6.3.4. Triggers

6.4. Themes

6.4.1. Using a specific theme

6.4.2. Changing themes from code

6.5. Summary

7. Events

7.1. Routed events

7.1.1. Bubbling events

7.1.2. Tunneling events

7.2. Events from code

7.2.1. handledEventsToo

7.2.2. Class events

7.3. Summary

8. Oooh, shiny!

8.1. Glass buttons

8.1.1. Styling the text

8.1.2. Adding glow when over buttons

8.1.3. Handling the button click

8.2. Adding some simple animation

8.2.1. Animating button glow

8.2.2. Animating a color

8.3. Reflections

8.4. Transforms

8.5. Summary

Part 3 Application development

9. Laying out a more complex application

9.1. Creating the Desktop Wiki Project

9.2. Nesting layouts

9.2.1. Preparing the layout for menus and toolbars

9.2.2. Adding menubars, statusbars, and toolbars…​

9.3. Nested layouts

9.3.1. Adding the first Grid

9.3.2. Adding the second Grid

9.3.3. Using a StackPanel and Expander as navigation aids

9.4. Summary

10. Commands

10.1. A brief history of commands

10.1.1. Windows Forms and simple event handlers

10.1.2. Son of MFC

10.2. The WPF approach

10.2.1. The Command pattern

10.2.2. WPF commands

10.3. Using the built-in system commands

10.3.1. ApplicationCommands

10.3.2. NavigationCommands

10.3.3. EditingCommands

10.3.4. Component and media commands

10.4. Handling commands

10.4.1. Handling a built-in command

10.4.2. Creating a custom command

10.4.3. Shortcuts and gestures

10.5. Command routing

10.6. A cleaner custom command implementation

10.6.1. Implementing a RoutedUICommand

10.6.2. Adding a CommandBinding

10.7. Summary

11. Data binding with WPF

11.1. WPF data binding

11.2. ProcessMonitor: A simple binding example

11.2.1. Binding Data with XAML

11.2.2. Binding in code

11.2.3. Binding notation and options

11.3. Binding to XML

11.3.1. Creating the CVE Viewer application

11.3.2. Binding controls to XML

11.3.3. XPath binding notation

11.3.4. Path versus XPath

11.3.5. Understanding and using DataContexts

11.3.6. Master-Detail Binding

11.4. Binding to ADO.NET database objects

11.4.1. Creating a bookmark utility

11.4.2. Creating the simple DAL

11.4.3. Laying out the UI and creating data bindings

11.5. Binding to business objects

11.5.1. Creating a WikiPage business object

11.5.2. ObservableCollection

11.5.3. Create a model façade

11.5.4. Wiring business objects to presentation objects

11.6. Binding to LINQ data

11.7. Summary

12. Advanced data templates and binding

12.1. Data converters

12.1.1. Formatting bound data with StringFormat

12.1.2. A number to formatted string data converter

12.1.3. Converter parameters

12.2. DataTriggers

12.3. CollectionViewSource

12.3.1. Sorting with CollectionViewSource

12.3.2. Programatically sorting with CollectionViewSource

12.3.3. Filtering with CollectionViewSource

12.4. Conditional templates

12.4.1. A more involved template

12.4.2. Conditionally using a template

12.4.3. Templates based on type

12.5. Validators

12.5.1. The ExceptionValidationRule

12.5.2. Custom ErrorTemplates

12.5.3. Custom validation rules

12.6. Model-View-ViewModel

12.7. Advanced binding capabilities

12.7.1. Hierarchical binding

12.7.2. MultiBinding

12.7.3. PriorityBinding

12.8. Summary

13. Custom controls

13.1. Composing new user controls

13.1.1. Building a LinkLabel control

13.1.2. Testing the LinkLabel UserControl

13.2. Building custom controls

13.2.1. Building a control library

13.2.2. Create the new custom control

13.2.3. Create the default template for the control

13.2.4. Testing the control

13.2.5. Customizing a custom control with a template

13.3. Summary

14. Drawing

14.1. Drawing with Shapes

14.1.1. Shapes in XAML

14.1.2. Stupid shape tricks

14.2. Creating the graphing control

14.2.1. Building the GraphHolder control

14.2.2. Graphing using shapes

14.2.3. Catching clicks

14.2.4. The downside of Shapes

14.3. Drawing with direct rendering

14.3.1. Recreating the graph control

14.3.2. Pluses and minuses of direct rendering

14.4. Drawing with Visuals

14.4.1. Control for display Visuals

14.4.2. Hit testing with Visuals

14.4.3. Adding labels to our graph

14.5. Drawings and Geometries

14.5.1. GeometryDrawing

14.5.2. Using Drawings

14.6. Summary

15. Drawing in 3D

15.1. Lights, camera…​

15.1.1. Models

15.1.2. Lights

15.1.3. Cameras

15.2. Graphing in 3D

15.3. 3D Transforms

15.3.1. A 3D Transform in XAML

15.3.2. A 3D Transform in code

15.4. Summary

Part 4 The last mile

16. Building a navigation application

16.1. When and where to use navigation applications

16.2. Creating a basic navigation application

16.2.1. Adding some navigation

16.2.2. Implementing dictionary lookup

16.2.3. Navigating programmatically

16.3. Page functions

16.3.1. Creating a Page function

16.3.2. Calling a page function

16.4. Summary

17. WPF and browsers: XBAP, ClickOnce, and Silverlight

17.1. Building an XBAP

17.1.1. XBAP security

17.1.2. Deploying an XBAP

17.1.3. When to use XBAP

17.2. Using ClickOnce

17.2.1. Deploying a WPF application via ClickOnce

17.2.2. When to use ClickOnce

17.3. Using Silverlight

17.4. Summary

18. Printing, documents, and XPS

18.1. Printing flow documents

18.1.1. Setting up to print

18.1.2. Customizing the output

18.1.3. Printing asynchronously

18.2. Printing FixedDocuments

18.2.1. Adding some FlowDocument content to our FixedDocument

18.2.2. Matching resolution

18.2.3. Printing Visuals

18.3. XPS

18.3.1. Saving an XPS document to a file

18.3.2. The problem with images…​

18.4. Summary

19. Transition effects

19.1. Building the World Browser application

19.1.1. The DictionaryLookup class

19.1.2. Working with the Application object

19.1.3. Our WorldListView user control

19.1.4. Populating the country list

19.2. Adding a simple transition

19.3. Building a generic transition control

19.3.1. Creating the transition control

19.3.2. Using the transition control

19.3.3. Defining a ControlTemplate for our control

19.3.4. Using the ABSwitcher

19.4. Adding some interesting transition effects

19.4.1. The fade effect

19.4.2. Wipe effect

19.4.3. Adding a selector for effects

19.5. Summary

20. Interoperability

20.1. Using Windows Forms controls in WPF

20.1.1. Using the Windows Forms DateTimePicker in WPF

20.1.2. Enabling Windows themes for Windows Forms control

20.1.3. What you can’t do with embedded Windows Forms controls

20.1.4. Using your own Windows Forms controls

20.1.5. Popping up Windows Forms dialogs

20.2. Embedding ActiveX and C++ in WPF

20.2.1. Embedding ActiveX controls in WPF

20.2.2. Embedding C++ controls in WPF

20.3. Using WPF in Windows Forms

20.3.1. Using a WPF control inside of Windows Forms

20.3.2. Popping up WPF dialogs

20.4. Summary

21. Threading

21.1. Moving slow work into a background thread

21.2. Asynchronous calls

21.3. Timers

21.4. Summary


About the Technology

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.

About the book

Written in a witty, engaging style, WPF in Action with Visual Studio 2008 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.

What's inside

  • WPF using Visual Studio 2008
  • Real-world example applications
  • Tips and techniques
  • Advice for Windows Forms developers
  • Drawing and animation
  • Command handling and data-binding
  • XBAP and ClickOnce

About the authors

Arlen Feldman specializes in meta-data driven applications, particularly focusing on usability issues. He was chief architect for the award-winning HEAT software product, and has been working with .NET since its earliest days. He worked with Microsoft on the direction of .NET, the C# language, and Visual Studio as a member of the C# customer advisory group. Arlen is the author of ADO.NET Programming (Manning, 2003), and is the Chief Architect for Cherwell Software.

Maxx Daymon learned BASIC before he learned English. He is MCPD Certified with specialization in both Windows and Web development, and has been working with .NET since its preview releases. He has broad development experience in both internal and external software development, and specializes in metaprogramming and agile development. He is currently a software platform architect at Configuresoft, a leading developer of configuration management and compliance software.

eBook $35.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

Excellent real-world code examples.

Nishant Sivakumar, Microsoft MVP

A thorough step-by-step guide for Visual Studio users.

Jeff Maurone, MSNBC.com

Required reading for all WPF designers and developers.

Donald Burnett, Microsoft Phizzpop.com

The definitive source on WPF.

Aleksey Nudelman, C# Computing, LLC

A great, detailed jumpstart into practical WPF development.

Joe Stagner, Microsoft