PacktLib: Windows Presentation Foundation 4.5 Cookbook

Windows Presentation Foundation 4.5 Cookbook


About the Author

About the Reviewers




Creating custom type instances in XAML

Creating a dependency property

Using an attached property

Creating an attached property

Accessing a static property from XAML

Creating a custom markup extension

Handling routed events



Using logical resources

Dynamically binding to a logical resource

Using user-selected colors and fonts

Using binary resources

Accessing binary resources in code

Accessing binary resources from another assembly

Managing logical resources

Layout and Panels


Creating a table-like user interface

Dynamically sizing grid rows/columns

Creating a scrollable user interface

Creating a border around panels and elements

Placing elements in exact positions

Adding/removing elements to a panel dynamically

Creating a tabbed user interface

Implementing drag-and-drop

Using Standard Controls


Working with text

Using content controls

Displaying images

Creating tooltips

Creating a list of items

Creating a standard menu

Creating a context menu

Selecting options with checkboxes and radio buttons

Manipulating tab order and focus

Application and Windows


Creating a window

Creating a dialog box

Using the common dialog boxes

Creating ownership between windows

Creating a custom shaped window

Creating a single instance application

Handling an unhandled exception

Data Binding


Element to element binding

Binding to a single object

Binding to a collection

Using data templates

Using value converters

Creating a master-detail view

Sorting and filtering bound collections

Grouping bound collections

Binding to multiple properties

Binding hierarchical data to a TreeView

Presenting data in a grid

Validating data

Commands and MVVM


Using routed commands

Implementing a basic MVVM application

Building a simple MVVM framework

Building a complete MVVM style application

Creating an undo/redo system

Styles, Triggers, and Control Templates


Creating and using styles

Applying a style automatically

Creating a property trigger

Using data triggers

Creating an event trigger

Creating a multi trigger

Using behaviors

Replacing the control template of a progress bar

Replacing the control template of a scroll bar

Customizing selection in a Selector control

Graphics and Animation


Creating a custom shape

Applying transforms on elements

Manipulating a bitmap programmatically

Creating adorners

Creating property-based animations

Creating path-based animations

Creating custom animations

Adding animation easing to animations

Using custom effects with pixel shaders

Custom Elements


Creating a user control

Handling standard commands in a user control

Creating a custom (templated) control

Customizing a default template of custom control

Creating a custom panel

Creating a lightweight custom element



Updating the UI from a non-UI thread

Adding cancelation support

Using the BackgroundWorker component

Adding cancellation and progress with BackgroundWorker

Using a timer to do periodic updates

Using C# 5.0 to perform asynchronous operations