WPF Control Development Unleashed: Building Advanced User Experiences [NOOK Book]


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 ...

See more details below
WPF Control Development Unleashed: Building Advanced User Experiences

Available on NOOK devices and apps  
  • NOOK Devices
  • Samsung Galaxy Tab 4 NOOK
  • NOOK HD/HD+ Tablet
  • NOOK
  • NOOK Color
  • NOOK Tablet
  • Tablet/Phone
  • NOOK for Windows 8 Tablet
  • NOOK for iOS
  • NOOK for Android
  • NOOK Kids for iPad
  • PC/Mac
  • NOOK for Windows 8
  • NOOK for PC
  • NOOK for Mac

Want a NOOK? Explore Now

NOOK Book (eBook)
BN.com price
(Save 42%)$39.99 List Price


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

Read More Show Less

Product Details

  • ISBN-13: 9780768695489
  • Publisher: Pearson Education
  • Publication date: 9/25/2009
  • Series: Unleashed
  • Sold by: Barnes & Noble
  • Format: eBook
  • Edition number: 1
  • Pages: 384
  • File size: 16 MB
  • Note: This product may take a few minutes to download.

Meet the Author

Pavan Podila, Architect at NYC’s Liquidnet Holdings, has worked extensively with many leading UI technologies, including WPF/Silverlight, Flash/Flex/AIR, and DHTML. In the past, he has worked with Java Swing, Eclipse SWT, and TrollTech/Nokia Qt. His primary interests include 2D/3D graphics, data visualization, UI architecture, and computational art. He created FluidKit (fluidkit.codeplex.com), an open-source WPF library of controls such as ElementFlow, TransitionPresenter, etc. He is a Microsoft MVP for Client App Dev and blogs actively at blog.pixelingene.com.

Kevin Hoffman got his first computer, a Commodore VIC-20, when he was 10 years old and has been hopelessly addicted to programming ever since. He has written desktop applications, web applications, distributed enterprise applications, VoIP software, and pretty much everything else in between. He is currently a .NET Architect in New England building large-scale, next-generation web applications.

Read More Show Less

Table of Contents

About the Authors xii

Dedications xiii

We Want to Hear from You! xv

Part I Thinking in WPF

1 The WPF Design Philosophy 1

Data and Behavior 2

Working with Data 3

Templates 3

Presenters 4

Binding and Converters 4

Layout 5

Styles 5

Working with Behaviors 6

The User Experience 8

The User Experience Benevolent Circle 9

A Note on Sample Source Code 9

Summary 10

2 The Diverse Visual Class Structure 11

Introducing the Visual Classes 11

The DispatcherObject Class 12

The DependencyObject Class 12

The Visual and DrawingVisual Classes 13

The FrameworkElement Class 15

The Shape Class 16

The Text Classes 18

The Control Class 19

The ContentControl Class 20

The ContentPresenter Class 20

The ItemsControl Class 21

The UserControl Class 22

The Panel Class 23

The Decorator Class 24

The Adorner Class 24

The Image Class 25

The Brushes 25

The DataTemplate, ControlTemplate, and ItemsPanelTemplate Classes 27

The Viewport3D Class 27

The MediaElement Class 28

The InkCanvas 28

Summary 29

3 Getting Started Writing Custom Controls 31

Overcoming the “Start from Scratch” Instinct 31

Using Data Transformations 32

Find the Behavior You Want, Then Extend 34

The Power of Attached Properties 35

Custom Control Creation Checklist 38

Thinking in Layers–The Art of Decomposition 39

Sample: Building a Circular Minute Timer 40

Enhancing and Extending the ProgressBar 40

Creating the Arc Shape 42

Working with the ControlTemplate 43

Summary 47

4 Building Custom Panels 49

Layout Defined 49

How Layout Works 51

Working with Visual Children 52

Creating a Custom Panel: The VanishingPointPanel 56

Building a Panel with Attached Properties: WeightedPanel 58

Using Transformations with Layout 63

Enter the LayoutTransform 66

Layout Events 66

Summary 68

5 Using Existing Controls 69

Customizing Existing Controls 70

Customizing Controls Using Properties 70

Customization Using Control Templates 70

Customization with Data Templates 71

Using a ControlTemplate and a DataTemplate 71

Customizing the ItemsControl 72

Customizing a ListBox 74

Customizing the ItemContainerStyle 74

Customizing the ItemTemplate and the ItemsPanelTemplate 77

Creating a Custom ScrollBar 78

Using Brushes to Create Advanced Visuals 82

Using the VisualTreeHelper and LogicalTreeHelper 82

Customization Sample–The Radar Screen 83

Moving Enemies in a ListBox 84

Concentric Circles and a Sweeping Cone 85

Summary 91

6 The Power of Attached Properties 93

Overview of Attached Properties 93

Building the UseHover Attached Property 95

Using Attached Properties as Extension Points 100

Data Templates 102

Property Abstraction 102

Layout Animations 102

Constraining Panels 102

Application Services 102

UI Helper Objects 103

Implementing Drag and Drop with Attached Properties 103

Summary 111

Part II Adding Complex Features

7 Advanced Scrolling 113

The Anatomy of a Scrollbar 113

The Magic of IScrollInfo 115

Responding to User-Requested Horizontal and Vertical Scrolling 116

Controlling the Bounds for the Track and Thumb 116

Managing the Location of the Thumb 116

Logical Scrolling 117

Building a Custom Panel with Custom Scrolling 117

Creating the Layout Logic 117

Adding the Scrolling Functionality 119

Animated Scrolling 122

Taking Scrolling to the Next Step 123

Scrolling Without IScrollInfo 124

Summary 127

8 Virtualization 129

Virtualization Distilled 129

Building Blocks of UI Virtualization 130

UI Virtualization in WPF 131

Component Interaction 132

A Deeper Look at the ItemContainerGenerator 133

Making Our Own Virtualized Control: The StaggeredPanel 135

Deferred Scrolling 139

Container Recycling 140

Virtualization in 3D 140

Summary 142

9 Creating Advanced Controls and Visual Effects 143

Lasso Selection Using the InkCanvas 143

Building a Dock Slide Presenter 146

Docking and Undocking Controls 149

Building a Transition Abstraction: The TransitionContainer 154

Handling Transitions 157

Applying a Transition 159

Implementing Popular Visual Effects 161

Reflection 161

Drop Shadows 163

Opacity Masks 164

Gloss Effects 164

Summary 166

10 Control Skinning and Themes 167

Introduction to Skins and Themes 168

Resource Lookups in WPF 168

Building Default Styles 169

Using Resources in Default Styles 170

Creating Theme-Specific Styles 172

Enabling Runtime Skinning 174

Using the ApplyTemplate Override 177

Control Customization Through Property Exposure 182

Summary 183

Part III Building Interactivity, 3D, Animations

11 Bridging the 2D and 3D Worlds 185

A Brief Introduction to 3D Worlds 185

Using the Viewport3D Element 186

Embedding a Viewport3D Element 189

Mapping 2D Visuals on 3D Surfaces 192

Getting Interactive with ModelUIElement3D and

ContainerUIElement3D 196

2D Bounds of a 3D Object 198

Hints on Layout in 3D 200

Interactive 2D-on-3D Surfaces 200

Summary 201

12 Custom Animations 203

Procedural Animations 203

Animating Using the DispatcherTimer 204

Animating Using CompositionTarget.Rendering 204

Animating with Storyboards 206

Simple Type-Based Animations (From, To, and By) 206

Keyframe Animations 207

Using Storyboards with Parallel Timelines 208

Using Path-Based Animations 211

Creating Custom Animations 212

Creating the 3D Surfaces 219

Animating Within the DrawingContext 220

Summary 221

13 Pixel Shader Effects 223

New and Improved Bitmap Effects 224

Working with Shaders 224

Setting Up the Environment 224

An Overview of HLSL 225

Writing Custom Shaders 228

Grayscale Shader 228

Building a Parameterized Shader: TwirlEffect 231

Animating the Shader Effects 235

Effect Mapping for GUI Interaction and Eventing 235

Multi-Input Shaders 239

A Useful Tool 242

Summary 242

Part IV Bringing the Controls to the Real World

14 Events, Commands, and Focus 243

Routed Events 243

Routed Events, Event Triggers, and Property Mirrors 245

Attached Events 246

Class Handlers 249

Weak Events Using Weak References 250

Implementing the Weak Event Pattern 251

Subclassing the Weak Event Manager 252

Delivering Events Via the IWeakEventListener 254

Commands 255

Routed Commands 259

Commands Versus Events 259

Request Requery 261

The ICommandSource Interface 262

Focus Management 266

Logical and Keyboard Focus 266

Focus-Related Events and Properties 267

Keyboard Navigation 271

Summary 273

15 Advanced Data Binding 275

Dependency Properties 276

Dependency Property Precedence 276

Using AddOwner Instead of Creating a New DependencyProperty 279

Listening to Property Changed Events on Dependency Properties 280

Special Data Binding Scenarios 282

Using RelativeSource.PreviousData 282

Using NotifyOnSourceUpdated and NotifyOnTargetUpdated 284

The Dispatcher and DispatcherPriority 285

Deferring UI Operations 287

Posting Messages from Worker Threads 287

The BackgroundWorker Class 289

Introduction to Continuous LINQ (CLINQ) 291

Summary 292

16 Control and Visual Design Tips 295

Control Design Tips 295

Use Internal Resource Dictionaries 295

Define Complex Controls as Partial Classes 296

Use Scoped Dependency Properties for Internal State Management 296

Use Attached Properties for Adding Functionality 297

Compose Graphics Using Simpler Building Blocks 297

Communicating Between a Control and Its Subparts 297

Use a State Machine to Handle Multiple Events and Property Changes 299

Use Low-Priority Delegates for Noncritical Tasks 299

Use x: Shared for Cloning Resources 299

Use Markup Extensions to Encapsulate Object Creation 300

Useful Patterns for GUI Development 301

The Strategy Pattern 301

The Builder Pattern 301

Model-View-Controller 302

Model-View-View Model 302

Factory Method 303

Composed Method 303

State Pattern 303

Code Should be Idiomatic with Regard to“Framework Design Guidelines” 304

Visual Design Tips 304

Using Tile Brushes 304

Using Gradients with Relative Transforms 306

XAML Coding Conventions 307

Use the Vista Interface Guidelines 308

Using Nonstandard Fonts for Icons 308

Using Transparent PNGs 309

Import from Photoshop and Illustrator 309

Opacity Masks 310

Using Clip Geometries 310

Some Useful Tools 312

Snoop 312

Mole 313

Kaxaml 313

Summary 315

17 Performance 317

Different Kinds of Performance 318

Choice of Visuals 318

Brushes and Caching 320

Resource Management 321

Reference Handling 321

Data Binding and Freezables 321

Background Threads for Long-Running Operations 322

Scrolling and Virtualization 322

Storyboard Animations 323

Pixel Shaders 323

Framework Property Metadata Options 323

RenderCapability–Hardware and Software Rendering 324

Optimizing the Render Pipeline 325

3D 325

Measuring Performance 326

Visual Profiler 327

Perforator 328

Third-Party Tools 329

Perceived Responsiveness 329

Summary 330

18 Control Automation 331

The Need for UI Automation 331

The Automation Object Model 332

Assemblies and Namespaces 333

AutomationElement, AutomationPeer, and Control Patterns 333

Automation Properties 335

Navigating the Automation Tree 336

Using the Automation API 338

Locating Elements in the Automation Tree 339

Checking for Control Patterns 340

Looking Up Property Values 341

Listening to Events 341

Navigating to the Parent, Child, or Sibling 342

Performing Operations on Automation Elements 342

Automation of a Custom Control 343

Picking a Base Peer Class 343

Picking Pattern Interfaces, aka the Control Patterns 344

Building RangeSelectorAutomationPeer 345

Additional Resources 349

Summary 349

Index 351

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star


4 Star


3 Star


2 Star


1 Star


Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation


  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously
Sort by: Showing all of 2 Customer Reviews
  • Anonymous

    Posted November 30, 2009

    No text was provided for this review.

  • Anonymous

    Posted September 21, 2009

    No text was provided for this review.

Sort by: Showing all of 2 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)