- Animation
- Application design
- ASP.NET
- C#, .NET 3.5
- Controls
- Data access
- Effects
- Expression Blend
- Expression Design
- Game development
- Graphics
- Javascript and AJAX
- Math and Physics
- Media streaming
- Multimedia
- Security
- Silverlight
- Styling
- UI Design
- VB.NET
- Video
- Visual Studio
- WCF
- WPF
- XAML

BlueForest Networks

WPF Control Development Unleashed: Building Advanced User Experiences
Publisher: Sams - September 21, 2009 ISBN-10: 0672330334, ISBN-13: 9780672330339
Author: Pavan Podila
Kevin Hoffman
384 pages
WPF Control Development Unleashed: Building Advanced User Experiences - book reviews: 9
WPF Control Development Unleashed
Building Advanced User Experiences
In this book, two leading Windows Presentation Foundation experts give developers everything they need to build next-generation WPF applications–software that is more robust, usable, and compelling.
Drawing on their close ties with Microsoft’s WPF development team, Pavan Podila and Kevin Hoffman give you a clear, robust, and practical understanding of WPF, its underpinnings, its overall architecture, and its design philosophy. Podila and Hoffman introduce never-before-published WPF design patterns and support them with robust, real-world code examples–all presented in full color, just as they appear in Visual Studio.
The authors begin by explaining how to “think in WPF,” and then introduce powerful new techniques for everything from handling 3D layouts to creating game-like physics effects. Along the way, they offer in-depth coverage of data binding, building interactivity, and control development: three of WPF’s most challenging concepts. You’ll learn how to choose the right WPF features for every programming challenge, and use those features far more creatively and effectively.
If you want to build truly outstanding WPF applications, this is the book that will get you there.
- Master the patterns and techniques you need to build state-of-the-art WPF applications
- Write more powerful and effective applications that reflect a deep understanding of WPF’s design philosophy
- Learn how WPF has evolved, and take full advantage of its growing sophistication
- Make the most of advanced declarative programming techniques
- Leverage IScrollInfo, virtualization, control theming, and other complex features
- Build more powerful interactivity into your WPF applications
- Create more visual software with 3D elements, custom animations, and shader effects
- Optimize WPF application performance in real-world environments
- Master design patterns for organizing your controls more effectively
Category: .NET Programming / WPF
Covers: Windows Presentation Foundation
User Level: Intermediate—Advanced
About the Authors
Dedications
We Want to Hear from You!
Part I Thinking in WPF
The WPF Design Philosophy
Data and Behavior
Working with Data
Templates
Presenters
Binding and Converters
Layout
Styles
Working with Behaviors
The User Experience
The User Experience Benevolent Circle
A Note on Sample Source Code
Summary
The Diverse Visual Class Structure
Introducing the Visual Classes
The DispatcherObject Class
The DependencyObject Class
The Visual and DrawingVisual Classes
The FrameworkElement Class
The Shape Class
The Text Classes
The Control Class
The ContentControl Class
The ContentPresenter Class
The ItemsControl Class
The UserControl Class
The Panel Class
The Decorator Class
The Adorner Class
The Image Class
The Brushes
The DataTemplate, ControlTemplate, and ItemsPanelTemplate Classes
The Viewport3D Class
The MediaElement Class
The InkCanvas
Summary
Getting Started Writing Custom Controls
Overcoming the “Start from Scratch” Instinct
Using Data Transformations
Find the Behavior You Want, Then Extend
The Power of Attached Properties
Custom Control Creation Checklist
Thinking in Layers–The Art of Decomposition
Sample: Building a Circular Minute Timer
Enhancing and Extending the ProgressBar
Creating the Arc Shape
Working with the ControlTemplate
Summary
Building Custom Panels
Layout Defined
How Layout Works
Working with Visual Children
Creating a Custom Panel: The VanishingPointPanel
Building a Panel with Attached Properties: WeightedPanel
Using Transformations with Layout
Enter the LayoutTransform
Layout Events
Summary
Using Existing Controls
Customizing Existing Controls
Customizing Controls Using Properties
Customization Using Control Templates
Customization with Data Templates
Using a ControlTemplate and a DataTemplate
Customizing the ItemsControl
Customizing a ListBox
Customizing the ItemContainerStyle
Customizing the ItemTemplate and the ItemsPanelTemplate
Creating a Custom ScrollBar
Using Brushes to Create Advanced Visuals
Using the VisualTreeHelper and LogicalTreeHelper
Customization Sample–The Radar Screen
Moving Enemies in a ListBox
Concentric Circles and a Sweeping Cone
Summary
The Power of Attached Properties
Overview of Attached Properties
Building the UseHover Attached Property
Using Attached Properties as Extension Points
Data Templates
Property Abstraction
Layout Animations
Constraining Panels
Application Services
UI Helper Objects
Implementing Drag and Drop with Attached Properties
Summary
Part II Adding Complex Features
Advanced Scrolling
The Anatomy of a Scrollbar
The Magic of IScrollInfo
Responding to User-Requested Horizontal and Vertical Scrolling
Controlling the Bounds for the Track and Thumb
Managing the Location of the Thumb
Logical Scrolling
Building a Custom Panel with Custom Scrolling
Creating the Layout Logic
Adding the Scrolling Functionality
Animated Scrolling
Taking Scrolling to the Next Step
Scrolling Without IScrollInfo
Summary
Virtualization
Virtualization Distilled
Building Blocks of UI Virtualization
UI Virtualization in WPF
Component Interaction
A Deeper Look at the ItemContainerGenerator
Making Our Own Virtualized Control: The StaggeredPanel
Deferred Scrolling
Container Recycling
Virtualization in 3D
Summary
Creating Advanced Controls and Visual Effects
Lasso Selection Using the InkCanvas
Building a Dock Slide Presenter
Docking and Undocking Controls
Building a Transition Abstraction: The TransitionContainer
Handling Transitions
Applying a Transition
Implementing Popular Visual Effects
Reflection
Drop Shadows
Opacity Masks
Gloss Effects
Summary
Control Skinning and Themes
Introduction to Skins and Themes
Resource Lookups in WPF
Building Default Styles
Using Resources in Default Styles
Creating Theme-Specific Styles
Enabling Runtime Skinning
Using the ApplyTemplate Override
Control Customization Through Property Exposure
Summary
PartIII BuildingInteractivity, 3D, Animations
Bridging the 2D and 3D Worlds
A Brief Introduction to 3D Worlds
Using the Viewport3D Element
Embedding a Viewport3D Element
Mapping 2D Visuals on 3D Surfaces
Getting Interactive with ModelUIElement3D and
ContainerUIElement3D
2D Bounds of a 3D Object
Hints on Layout in 3D
Interactive 2D-on-3D Surfaces
Summary
Custom Animations
Procedural Animations
Animating Using the DispatcherTimer
Animating Using CompositionTarget.Rendering
Animating with Storyboards
Simple Type-Based Animations (From, To, and By)
Keyframe Animations
Using Storyboards with Parallel Timelines
Using Path-Based Animations
Creating Custom Animations
Creating the 3D Surfaces
Animating Within the DrawingContext
Summary
Pixel Shader Effects
New and Improved Bitmap Effects
Working with Shaders
Setting Up the Environment
An Overview of HLSL
Writing Custom Shaders
Grayscale Shader
Building a Parameterized Shader: TwirlEffect
Animating the Shader Effects
Effect Mapping for GUI Interaction and Eventing
Multi-Input Shaders
A Useful Tool
Summary
Part IV Bringing the Controls to the Real World
Events, Commands, and Focus
Routed Events
Routed Events, Event Triggers, and Property Mirrors
Attached Events
Class Handlers
Weak Events Using Weak References
Implementing the Weak Event Pattern
Subclassing the Weak Event Manager
Delivering Events Via the IWeakEventListener
Commands
Routed Commands
Commands Versus Events
Request Requery
The ICommandSource Interface
Focus Management
Logical and Keyboard Focus
Focus-Related Events and Properties
Keyboard Navigation
Summary
Advanced Data Binding
Dependency Properties
Dependency Property Precedence
Using AddOwner Instead of Creating a New DependencyProperty
Listening to Property Changed Events on Dependency Properties
Special Data Binding Scenarios
Using RelativeSource.PreviousData
Using NotifyOnSourceUpdated and NotifyOnTargetUpdated
The Dispatcher and DispatcherPriority
Deferring UI Operations
Posting Messages from Worker Threads
The BackgroundWorker Class
Introduction to Continuous LINQ (CLINQ)
Summary
Control and Visual Design Tips
Control Design Tips
Use Internal Resource Dictionaries
Define Complex Controls as Partial Classes
Use Scoped Dependency Properties for Internal State Management
Use Attached Properties for Adding Functionality
Compose Graphics Using Simpler Building Blocks
Communicating Between a Control and Its Subparts
Use a State Machine to Handle Multiple Events and Property Changes
Use Low-Priority Delegates for Noncritical Tasks
Use x: Shared for Cloning Resources
Use Markup Extensions to Encapsulate Object Creation
Useful Patterns for GUI Development
The Strategy Pattern
The Builder Pattern
Model-View-Controller
Model-View-View Model
Factory Method
Composed Method
State Pattern
Code Should be Idiomatic with Regard to“Framework Design Guidelines”
Visual Design Tips
Using Tile Brushes
Using Gradients with Relative Transforms
XAML Coding Conventions
Use the Vista Interface Guidelines
Using Nonstandard Fonts for Icons
Using Transparent PNGs
Import from Photoshop and Illustrator
Opacity Masks
Using Clip Geometries
Some Useful Tools
Snoop
Mole
Kaxaml
Summary
Performance
Different Kinds of Performance
Choice of Visuals
Brushes and Caching
Resource Management
Reference Handling
Data Binding and Freezables
Background Threads for Long-Running Operations
Scrolling and Virtualization
Storyboard Animations
Pixel Shaders
Framework Property Metadata Options
RenderCapability–Hardware and Software Rendering
Optimizing the Render Pipeline
3D
Measuring Performance
Visual Profiler
Perforator
Third-Party Tools
Perceived Responsiveness
Summary
Control Automation
The Need for UI Automation
The Automation Object Model
Assemblies and Namespaces
AutomationElement, AutomationPeer, and Control Patterns
Automation Properties
Navigating the Automation Tree
Using the Automation API
Locating Elements in the Automation Tree
Checking for Control Patterns
Looking Up Property Values
Listening to Events
Navigating to the Parent, Child, or Sibling
Performing Operations on Automation Elements
Automation of a Custom Control
Picking a Base Peer Class
Picking Pattern Interfaces, aka the Control Patterns
Building RangeSelectorAutomationPeer
Additional Resources
Summary
Index
Much Needed Book on Building WPF Controls
I've been writing apps for business and pleasure in WPF for 2.5 years now. I own every significant book on WPF that is out there. Most are quite good, and can do a nice job showing Joe Developer how to build an app in WPF by teaching about the out-of-the-box controls, basic data binding, validation, DataTemplates, ControlTemplates, Styles, Triggers, etc. That sort of book can get you building an app that looks very nice and leaves its WinForms battleship gray apps in the dust.
However, actually building custom controls in WPF is a topic that is barely glanced upon in most of those books. Furthermore, there simply wasn't much information specifically on the topic of building your own WPF controls on MSDN. The best sources where blogs such as Josh Smith, Dr WPF, and Pavan Podila (one of the authors). But a book that systematically covered the topic was a void that has been very nicely filled by WPF Control Development Unleashed. This is great because well-done custom controls can really increase the "sizzle" of an app and make it enjoyable to use.
As others have written, this book isn't for someone who is just learning WPF. It is for some advanced developers who are building their own WPF controls. On the first page the authors explain that they are going to teach the "whys" of WPF so that compelling apps can be built, and that they are also maintainable and can stand the test of time because they are built in accordance with the WPF design philosophy. I think the book does a great job of achieving that goal.
One of the biggest strengths of the book is that it spends time showing when NOT to build a custom WPF control in favor of re-templating existing controls. They creatively give a number of examples of this, including using a WPF ListBox to actually display an animated radar screen! Re-purposing existing controls through their ControlTemplates should always be explored before actually building a new custom WPF Control. They also cover the WPF class hierarchy and explain that when building a custom WPF control it is very important to subclass from the correct WPF class.
My favorite chapters were "Building Custom Panels", "Using Existing Controls", "Advanced Scrolling", "Virtualization", "Custom Animations", "Events, Commands, and Focus", and "Advanced Data Binding". These chapters delve into the plumbing of WPF in ways other books don't. Unless you are a WPF rockstar you will learn lots of new things about these topics. Maybe you'll learn about the levels of data binding precedence, or how you can receive change notification for dependency properties that a control doesn't provide an event for, new ways to use Attached Properties--or maybe just some guidelines over when to use Commands or RoutedEvents. You will learn something you didn't know before, even about WPF topics you have used extensively.
Is this book perfect? No, of course not. It simply cannot cover everything about WPF in full detail. For instance, you will find some discussion of WPF design patterns (MVVM, etc) but as these are not the main focus of the book there wasn't room to cover them (and all their flavors). In fact I really think there would be room for a book entirely devoted to WPF flavors of UI design patterns. Despite a few minor shortcomings along these lines, I feel this book merits 5 stars.
The authors' examples of custom WPF controls and re-templated existing WPF controls are fantastic and all the code can be downloaded for free. In fact, if you just read the book and don't look at the code you are really missing out. Just using some of these controls really got some of my own creative juices flowing.
To end, here is what I (@adajos) tweeted about this book:
"The 5 most useful tips I found in WPF Control Development Unleashed. 1. Use AddOwner Instead of Creating a New DependencyProperty #WPF
2. Listen for PropertyChanged events on Dependency Properties with DependencyPropertyDescriptor's AddValueChanged() #WPF
3. How/when to do a Weak Event Pattern with IWeakEventListener and subclassing WeakEventManager. #WPF
4. The entire chapter on Virtualization in #WPF
5. Implementing Drag and Drop with Attached Properties. #WPF
Those were my 5 favorite tips from WPF Control Development Unleashed, but it was chock full of great content. Highly recommended. #WPF"
Joshua Adams
06 January, 2010
The book is horrible.
The book is horrible. If you expect to learn how to create controls, you will be disappointed unless you are already a guru in WPF in which case you know how to make controls and you don't need this book.
The very first example of "attached properties" is a piece of code that should be probably studied by cypher experts of Bletchley Park. Some blame goes to Microsoft for typical Redmond nonsense programming style but complete lack of good explanation is criminal. The example is full of convoluted code calls to unexplained myriad of strange classes without much of an explanation why than has to be done that way. After that example authors conclude that you already mastered "attached properties". Other examples and tricks are pretty much the same. Bunch of pieces of complicated code and not much explanation why code has to use particular classes or make specific calls. The underlying assumption is that you already have deep knowledge of WPF! Who in the right mind with deep knowledge would need a book to learn basics of controls? Lot of text is devoted to useless comparisons of writing code to building a house analogy. At the fourth chapter I was really sorry that there is no money back guarantee. The book is complete waste of money. On the sixth chapter I gave up. Anybody want to purchase cheap book out there (used up to the sixth chapter) ? I will be looking for a book that knows how to explain stuff to beginners. If you want to learn WPF custom controls look somewhere else.
Jacek Marchel
29 July, 2010
Inside the design of WPF custom controls
I would not say that this is my favorite WPF book, and I have eight of them. But, it gets into the narrow area of custom control design and how to make the WPF jump through the hoops that you want want it to cover so you can learn how to teach it new tricks.
The book introduces the underlying hierarchy of classes that operate in control design and gives a summary explanation of their purpose. By chapter 5 the book is showing how to make some extreme, but conceptually useful modifications to common controls. A ring guage and a radar display panel are detailed in their design. Fllowing chapters cover use of properties, resources, and binding. Further chapters cover animation, visual effects, and skinning. Chapters 11, 12, and 13 cover 2D mapping into 3D projections, custom animations, and finally pixel shading. The final chapters cover commands, events, picture focus transition, and dependency properties.
Although I would have preferred a more in depth approach that would make the class hierarchy more immediately understandable, the book delivers on its premise that it cover some of the inner design capabilities of WPF controls. I received several useful viewpoints of a control's design potential and a very good idea of how to build extensions to common controls that will be useful in my future work.
In just under 350 pages, this book has upgraded my understanding of WPF controls to an expert level and given me food for thought. Now, don't misunderstand my rating of this material, the book is not complete until it gets into showing a complete design and distribution and covers use of the WPF custom control library project. For these reasons, I gave it only 4 stars.
If you are serious about getting WPF working well for you, your library will have at least four WPF books in it. There is no way to shorten the process, either do the reading or hire someone who has. I find discovering the extent of WPF designs to be intriguing and satisfying. Now I'm off to do some mindbending graphic displays. One of them is going to let me drill down into a sea of a hundred thousand 3D color sprites to find collections of spreadsheet pages and another is going to give me that enticing Miami:CSI Aero screen with touch input that makes crime solving look inviting.
Robin T. Wernick
31 March, 2010
Much more than a resource book.
As a WPF enthusiast, learning WPF at the hobby level has not afforded me the financial resources to travel to Redmond Washington for week-long boot-camps, nor attend extended seminars or workshops to grow my skills and experience. As a result, my only recourse has been to utilize those resources available on the Internet, supplemented with whatever subject-matter texts become available. Unfortunately however, the examples/tutorials available on the internet are typically over-simplistic without insight and many of the subject-matter books turn out to be single-issue recipe books. Although I am happy to have those references when I need to solve a specific issue or problem, I don't find that those types of resources have truly helped me expand my understanding and knowledge of WPF overall. With WPF's long-standing reputation for it's significant learning curve, as well as it's myriad of "moving-parts", the need for a more in-depth understanding as to the design philosophy and structure behind WPF becomes very important to becoming productive and being able to make the most of the framework.
This is where I believe WPF Controls Development Unleashed comes in and has truly distinguished itself. The book attempts to explain the workings "behind the WPF curtain", over-viewing the different thinking necessary from conventional programming to take advantage of the API. The authors provide numerous examples through the book that not only show `how' to customize a control or modify a behavior, but also provides the insight into the design architecture and/or thinking, which can be used straight across the platform. The book is well-written and a delight to read.
With the significant power latent in the WPF platform, I would prefer that any limitations imposed upon my developments would be as a result of my own creativity and skill-level, not what I am able to locate and copy from the internet. I believe WPF Control Development Unleashed attempts to fill-in that limitation-gap and although it may not replace that week-long pilgrimage to Redmond Washington for training, I believe it comes as close as any book can.
W. Hunter
24 March, 2010
Excellent book for the experienced
If you have experience with WPF this is an excellent book. It may not have all the detailed code but has all the meaty topics you need. If it had code for every little thing it talks about it would probably be a 900-page book and much less appealing. This is a 350-page book but very dense. Every page has tons of useful information.
It's a nice complement to Adam Nathan's book (ISBN 0672628917).
Gustavo Cavalcanti
30 October, 2009