http://archive.msdn.microsoft.com/wpfsamples
All Samples
All SamplesThis download contains all of the WPF documentation samples in a single package.
Download
Getting Started with WPF
Introduction to Building WPF ApplicationsThis sample provides an introduction to the development of a simple WPF application, and demonstrates controls, images, layout, and data binding.
Download |
Getting Started with WPFWPF Controls Gallery SampleThis sample shows common usage scenarios and the default rendering behavior for many user interfaces and layout controls in WPF.
Download |
System.Windows.Controls Namespace
Application Samples
Video Viewer DemoThis sample creates a video viewing application that demonstrates styling, data binding, and data templating features.
Download |
Styling and TemplatingData Binding DemoThis sample creates a product listing application that allows users to enter items for sale. This sample demonstrates several data binding concepts.
Download |
Data Binding OverviewParticle Effects DemoThis sample application demonstrates how to produce particle effects within a System.Windows.Controls.Viewport3D.
Download |
Viewport3D ClassXBAP Hosting Silverlight SampleThis sample demonstrates how to host a Silverlight-based application in a XAML browser application (XBAP) and how to communicate between the host XBAP and the hosted Silverlight-based application.
Download |
WPF XAML Browser Applications Overview
WPF Windows Samples
MessageBox SampleThis sample demonstrates how to display a message box and get the message box return value.
Download |
Dialog Boxes OverviewDialog Box SampleThis sample demonstrates how to use message boxes and common dialog boxes. This sample also shows how to create and use both modal and modeless dialog boxes.
Download |
Dialog Boxes OverviewNotification Icon SampleThis sample demonstrates how to display an icon in the notification area.
Download |
NotifyIcon Class
WPF Fundamentals
Height Properties SampleThis sample shows the differences among the height-related properties in WPF.
Download |
How to: Set the Height Properties of an ElementWidth Properties Comparison SampleThis sample shows the differences among the width-related properties in WPF.
Download |
How to: Set the Width Properties of an Element
Input and Commands
Create a Custom RoutedCommand SampleThis sample shows how to create and use a custom System.Windows.Input.RoutedCommand.
Download |
Commanding Overview
Styles
Introduction to Styling and Templating SampleThis is a simple photo application that is designed to demonstrate how to use styling to create a visually compelling user experience.
Download |
Styling and Templating
Themes
Default WPF ThemesThe theme files in this section are created from the resource dictionaries containing each WPF theme and are provided as examples of how to create themes, as well as how to customize existing controls.
Download |
System.Windows.Controls Namespace
Threading
Single-Threaded Application with Long-Running Calculation SampleThis sample demonstrates how to keep the UI from becoming non-responsive in single threaded application which performs a long operation.
Download |
System.Windows.Threading Namespace
Controls
ListView with Multiple Views SampleThis sample shows how to create a System.Windows.Controls.ListView control that displays data in multiple view modes, which include the System.Windows.Controls.GridView and other custom view modes.
Download |
ListView OverviewTreeListView SampleThis sample shows how to create a custom TreeView that resembles the ListView when it uses the GridView.
Download |
TreeView ClassPopup Placement SampleThis sample creates a simple System.Windows.Controls.Primitives.Popup and lets the user position the System.Windows.Controls.Primitives.Popup.
Download |
Popup Placement Behavior
Control Customization
Styling with ControlTemplates SampleThis sample shows the System.Windows.Controls.ControlTemplate examples for the most common WPF controls. If you are replacing the System.Windows.Controls.ControlTemplate of a control, these examples are the best place to get started.
Download |
Styling and TemplatingNumericUpDown Custom Control with Theme and UI Automation Support SampleThis sample demonstrates how to create a custom control that supports theming and UI automation.
Download |
Control Authoring OverviewColorPicker Custom Control SampleThis sample shows how to create a custom control and display it in a dialog window. This sample defines a custom color picker control that enables users to browse colors by their hue, saturation, and brightness.
Download |
Dialog Boxes OverviewResizingAdorner SampleThis sample implements a simple adorner that adds resizing handles to the element to which it is applied.
Download |
Adorner Class
Custom Radial Panel Sample
This sample shows how to derive a custom layout object from System.Windows.Controls.Panel that arranges its child elements in a radial pattern.
Download | Layout System
Create a Custom Content-Wrapping Panel Sample
This sample shows how to override the default layout behavior of the System.Windows.Controls.Panel element.
Download | How to: Create a Custom Panel Element
Layout
WPF Layout Gallery SampleThis sample provides a set of overview documents and samples that visually introduce you to the layout system in WPF.
Download |
Layout System
Data Binding
Binding Validation SampleThis sample shows how to implement data validation on the UI layer using binding.
Download |
How to: Implement Binding ValidationIntroduction to Data Templating SampleThis sample demonstrates how to use System.Windows.DataTemplate, System.Windows.DataTrigger, and System.Windows.Controls.DataTemplateSelector to specify the presentation of your data.
Download |
Data Templating OverviewChanging a Collection by Using IEditableCollectionView SampleThis sample uses the members that are provided by the System.ComponentModel.IEditableCollectionView interface to add and change items in a System.Windows.Controls.ListView.
Download |
IEditableCollectionView InterfaceSorting and Filtering Items in a View SampleThis sample shows how to use a collection view to apply a sort order and filtering.
Download |
How to: Filter Data in a View
Drag and Drop
Drag and Drop an Object on a Canvas SampleThis example shows how to move objects on a System.Windows.Controls.Canvas using drag and drop. In addition, this sample shows how to apply an adorner and an animation to the object as it is being moved.
Download |
Drag and Drop OverviewLoad a Dropped File SampleThis sample will open and display the contents of a text file dropped on the sample.
Download |
DataObject ClassThumb Drag Functionality SampleThis example shows how to use a System.Windows.Controls.Primitives.Thumb to resize a System.Windows.Controls.Canvas control by responding to the System.Windows.Controls.Primitives.Thumb.DragDelta event.
Download |
How to: Use a Thumb to Enable Dragging
Packaging
Reading a Package SampleThis sample shows how to read content, resource, and relationship parts from a XML Paper Specification (XPS) System.IO.Packaging.Package.
Download |
Documents in WPFWriting a Package SampleThis sample shows how to write content, resource, and relationship parts to a XML Paper Specification (XPS) System.IO.Packaging.Package.
Download |
Documents in WPFCreating a Package with a Digital Signature SampleThis sample shows how to write a XML Paper Specification (XPS) package with digitally signed content, and then read and validate the signed elements.
Download |
PackageDigitalSignatureManager Class
Typography
Advanced Text Formatting SampleThis sample shows how to create and use the Microsoft .NET Framework text engine.
Download |
Advanced Text Formatting
Brushes
Brushes SampleThis sample shows how to paint with solid colors, gradients, images, and drawings. It shows how to use features common to all brushes, such as the System.Windows.Media.Brush.Transform, System.Windows.Media.Brush.RelativeTransform, and System.Windows.Media.Brush.Opacity properties. It also demonstrates how to animate System.Windows.Media.SolidColorBrush and System.Windows.Media.GradientBrush objects.
Download |
WPF Brushes OverviewImageBrush SampleThis sample shows how to use an System.Windows.Media.ImageBrush to paint an area with an image. It also shows how to create patterns from an image.
Download |
WPF Brushes OverviewVisualBrush SampleThis sample shows how to use a System.Windows.Media.VisualBrush to paint an area with text, controls, and shapes. It also shows how to use a visual brush to magnify a portion of the screen and create a reflection.
Download |
WPF Brushes OverviewOpacity Masking SampleThis sample shows how to create opacity masks and apply them to elements.
Download |
DrawingBrush Class
Geometries
Geometries SampleThis sample shows how to create and use geometries.
Download |
Geometry OverviewPoint SampleThis sample demonstrates the different operations of the System.Windows.Point structure.
Download |
Point StructureVector SampleThis sample shows how to use the various methods and properties of the System.Windows.Vector structure.A list of radio buttons is created that selects the operation to perform.
Download |
Vector StructureClip Region SampleThis sample shows how to define System.Windows.UIElement.Clip regions.
Download |
How to: Animate a Clip RegionConverter SampleThis sample shows how to use the converter classes to convert an instance of a type into a string.
Download |
PointConverter Class
Images
ImageView SampleThis sample shows a simple image viewing utility using the System.Windows.Controls.Image and System.Windows.Media.Imaging.BitmapImage objects.
Download |
Imaging OverviewWin32 Sample CodecThis sample demonstrates how to create a custom codec can be built using the unmanaged WPF Imaging Component API.
Download |
Imaging Overview
Shapes
Shape Elements SampleThis sample shows how to draw by using the following System.Windows.Shapes.Shape elements:
System.Windows.Shapes.Ellipse, System.Windows.Shapes.Line, System.Windows.Shapes.Path, System.Windows.Shapes.Polygon, System.Windows.Shapes.Polyline, and System.Windows.Shapes.Rectangle.
Download |
WPF Graphics, Animation, and Media Overview
Transformations
2-D Transforms SampleThis sample shows how to create, use, and animate two-dimensional transforms.
Download |
Transforms OverviewMatrix SampleThis sample shows how to use the various methods and properties of the System.Windows.Media.Matrix structure.
Download |
Matrix Structure
3-D Graphics
3-D Hit Testing SampleThis sample provides information about hit testing on an animated 3-D model.
Download |
How to: Hit Test in a Viewport3D3-D Lights SampleThis sample shows how to use the various methods and properties of the System.Windows.Media.Media3D.AmbientLight, System.Windows.Media.Media3D.DirectionalLight, and System.Windows.Media.Media3D.PointLight, objects.
Download |
System.Windows.Media.Media3D Namespace3-D Mesh SampleThis sample shows how to build meshes and group models to compose a 3-D scene in procedural code.
Download |
Point3DCollection Class3-D Scene SampleThis sample shows how to create and draw in a 3-D scene.
Download |
3-D Graphics Overview3-D Scene Animation Rotation Code SampleThis sample shows how to animate a rotation transformation on a 3-D model in procedural code.
Download |
PerspectiveCamera Class3-D Solids SampleThis sample applies images to several different 3-D models and shows how to re-use application resources in building a 3-D scene.
Download |
System.Windows.Media.Media3D NamespaceAnimated Rotation Markup SampleThis sample shows how to animate a rotation transformation on a 3-D model.
Download |
3-D Transformations OverviewMatrixTransform3D Viewer SampleThis sample provides a 3-D scene and some basic controls to demonstrate the effects of different Matrix3D values on transformations applied to a 3-D model.
Download |
3-D Transformations OverviewPoint3D SampleThis sample shows how to use the various methods and properties of the System.Windows.Media.Media3D.Point3D structure.
Download |
Point3D StructurePoint4D SampleThis sample shows how to use the various methods and properties of the System.Windows.Media.Media3D.Point4D structure.
Download |
Point4D StructureQuaternion Viewer SampleThis sample provides a 3-D scene and some basic controls to demonstrate the effects of different quaternion values on transformations applied to a 3-D model.
Download |
System.Windows.Media.Media3D NamespaceSize3D SampleThis sample shows how to use the various methods and properties of the System.Windows.Media.Media3D.Size3D structure.
Download |
Size3D StructureVector3D SampleThis sample shows how to use the various methods and properties of the System.Windows.Media.Media3D.Vector3D structure.
Download |
Vector3D StructureUIElement3D Sphere SampleThis sample shows how to create a Sphere class that derives from System.Windows.UIElement3D.
Download |
UIElement3D ClassInteractive 2-D on 3-D SampleThis sample demonstrates how to place interactive 2-D content, a button in this case, on a 3D object, using the System.Windows.Media.Media3D.Viewport2DVisual3D class.
Download |
Viewport2DVisual3D ClassHandling Events in 3-D SampleThis sample demonstrates how to create 3-D objects that respond to events using the System.Windows.Media.Media3D.ContainerUIElement3D and System.Windows.Media.Media3D.ModelUIElement3D classes. In particular, this sample creates two cubes that respond to mouse-down events.
Download |
UIElement3D Class
Animations
Animation Example GalleryThis sample shows how to animate a variety of objects, include text, 2-D transforms, and 3-D transforms. It also demonstrates splined interpolation, path animations, and custom animations.
Download |
Animation OverviewAnimating the Opacity of an Element SampleThis sample shows how to animate the System.Windows.UIElement.Opacity of an element.
Download |
How to: Animate the Opacity of an Element or BrushAnimation Timing Behavior SampleThis sample shows how to specify when an animation starts, how many times it repeats, whether it accelerates or decelerates, and other timing behaviors.
Download |
Timing Behaviors OverviewCustom Animation SampleThis sample shows how to create custom animations that simulate bouncing and other interesting effects.
Download |
Custom Animations OverviewFrom, To, and By Animation Target Values SampleThis sample shows how to use the System.Windows.Media.Animation.DoubleAnimation.From, System.Windows.Media.Animation.DoubleAnimation.To, and System.Windows.Media.Animation.DoubleAnimation.By values of an animation.
Download |
From/To/By Animations OverviewKeyFrame Animation SampleThis sample shows how to use key frame animations to animate along a set of target values.
Download |
Key-Frame Animations OverviewKey Spline Animation SampleThis sample enables you to interactively adjust the key spline of a System.Windows.Media.Animation.DoubleAnimationUsingKeyFrames.
Download |
Key-Frame Animations OverviewPath Animation SampleThis sample shows how to animate an object along a geometric path.
Download |
Path Animations Overview
Visual Layer Programming
Using the CompositionTarget SampleThis sample illustrates how to use System.Windows.Media.CompositionTarget object to create custom drawings or animations based on a per-frame callback.
Download |
How to: Render on a Per Frame Interval Using CompositionTargetHit Test Using DrawingVisuals SampleThis sample demonstrates how to use System.Windows.Media.DrawingVisual objects to create lightweight graphics. The sample also shows how to implement hit testing at the visual object level.
Download |
Using DrawingVisual ObjectsHit Test with Win32 Interoperation SampleThis sample demonstrates how to use the default hit testing support in the visual layer of WPF.
Download |
Hit Testing in the Visual Layer
Globalization and Localization
Globalization Homepage SampleThis example demonstrates how to build and localize a Homepage.
Download |
WPF Globalization and Localization OverviewLocBaml Tool SampleThis sample demonstrates how to use the LocBaml tool to parse input files to create localizable resources and generate a localized binary. The C# files build the tool and the XAML files build a DLL to use as input for the LocBaml tool.
Download |
WPF Globalization and Localization Overview
Migration and Interoperability
Hosting a Windows Forms Control in WPF SampleThis sample demonstrates how to host a Windows Forms control in a WPF application.
Download |
Walkthrough: Hosting a Windows Forms Control in WPFHosting a Windows Forms Control in WPF by Using XAML SampleThis sample demonstrates how to host a Windows Forms control in a WPF application by using XAML.
Download |
Walkthrough: Hosting a Windows Forms Control in WPF by Using XAMLHosting a Windows Forms Composite Control in WPF SampleThis sample shows you how to host a Windows Forms data-entry composite control in a WPF application. It shows how to receive events and acquire data from the control and modify the control's properties.
Download |
Walkthrough: Hosting a Windows Forms Composite Control in WPFEnabling Visual Styles in a Hybrid Application SampleThis sample shows how to enable Microsoft Windows XP visual styles on a Windows Forms control hosted in a WPF-based application.
Download |
How to: Enable Visual Styles in a Hybrid ApplicationArranging Windows Forms Controls in WPF SampleThis sample shows how to use WPF layout features to arrange Windows Forms controls in a hybrid application.
Download |
Walkthrough: Arranging Windows Forms Controls in WPFData Binding in Hybrid Applications SampleThis sample shows how to bind WPF and Windows Forms controls to a common data source and display the results in a master/detail form.
Download |
Walkthrough: Binding to Data in Hybrid ApplicationsHosting a 3-D WPF Composite Control in Windows Forms SampleThis sample demonstrates how to host a WPF composite control that displays a three-dimensional (3-D) cone in a Windows Forms application.
Download |
Walkthrough: Hosting a 3-D WPF Composite Control in Windows FormsHosting a WPF Composite Control in Windows Forms SampleThis sample demonstrates how to host a WPF data-entry composite control in a Windows Forms application. It shows how to receive events and acquire data from the control and modify the control's properties.
Download |
Walkthrough: Hosting a WPF Composite Control in Windows FormsMapping Properties Using the ElementHost Control SampleThis sample shows how to use the System.Windows.Forms.Integration.ElementHost.PropertyMap property to map Windows Forms properties to corresponding properties on a hosted WPF element.
Download |
Walkthrough: Mapping Properties Using the ElementHost ControlMapping Properties Using the WindowsFormsHost Element SampleThis sample shows how to use the System.Windows.Forms.Integration.WindowsFormsHost.PropertyMap property to map WPF properties to corresponding properties on a hosted Windows Forms control.
Download |
Walkthrough: Mapping Properties Using the WindowsFormsHost ElementLocalizing a Hybrid Application SampleThis sample shows how to localize WPF elements in a Windows Forms-based hybrid application.
Download |
Walkthrough: Localizing a Hybrid ApplicationHosting a Win32 HWND in WPF SampleThis sample shows how to put an hwnd inside a WPF application.
Download |
WPF and Win32 InteroperationHosting a Win32 ListBox Control in WPF SampleHosts a Win32 ListBox control in a WPF application. This sample shows how to create and host the control, and how to send and receive messages.
Download |
Walkthrough: Hosting a Win32 Control in WPF