What is WPF?

The Windows Presentation Foundation (or WPF) is a graphical subsystem for rendering user interfaces in Windows-based applications. WPF, previously known as "Avalon", was initially released as part of .NET Framework 3.0. Designed to remove dependencies on the aging GDI subsystem, WPF is built on DirectX, which provides hardware acceleration and enables modern user interface (UI) features such as transparency, gradients, and transforms. WPF provides a consistent programming model for building applications and provides a clear separation between the user interface and the business logic.

WPF also offers a new markup language, known as XAML, which is an alternative means for defining UI elements and relationships with other UI elements. A WPF application can be deployed on the desktop or hosted in a web browser. It also enables rich control, design, and development of the visual aspects of Windows programs. It aims to unify a number of application services: user interface, 2D and 3D drawing, fixed and adaptive documents, advanced typography, vector graphics, raster graphics, animation, data binding, audio and video.

WPF is included with Windows 7, Windows Vista, and Windows Server 2008 and is also available for Windows XP Service Pack 2 or later, and Windows Server 2003.

Microsoft Silverlight is a web-based subset of WPF that enables Flash-like web and mobile applications with the same programming model as .NET applications. 3D features are not supported, but XPS and vector-based drawing are included.

 

Media Services

  • WPF provides an integrated system for building user interfaces with common media elements like vector and raster images, audio, and video. WPF also provides an animation system and a 2D/3D rendering system.[4]
  • WPF provides shape primitives for 2D graphics along with a built-in set of brushes, pens, geometries, and transforms.
  • The 3D capabilities in WPF are a subset of the full-feature set provided by Direct3D. However, WPF provides tighter integration with other features like user interfaces, documents, and media. This makes it possible to have 3D user interfaces, 3D documents, or 3D media.
  • There is support for most common image formats: BMP, JPEG, PNG, TIFF, Windows Media Photo, GIF, and ICON.
  • WPF supports the video formats WMV, MPEG and some AVI files by default, but since it has Windows Media Player running beneath, WPF can use all the codecs installed for it.
 

Layout

  • WPF provides a sophisticated layout system that handles the arrangement of all visual elements.
  • The layout engine uses a recursive two-phase system.
  • First is the measure phase, where every element in the UI tree is queried for its desired size.
  • Second is the arrange phase, where each element is instructed as to its actual size and location.
  • WPF ships with a handful of layout panels (StackPanel, WrapPanel, Canvas, UniformGrid, Grid, DockPanel) with each panel specializing in a particular type of layout.
  • WPF also provides a transformation engine.]
  • All transforms in WPF are eventually turned into Direct3D instructions which then become native GPU TRANSFORM instructions
  • WPF exposes a number of transform classes (Matrix, Rotation, Scale, Translate, Skew).
 

Templates

In WPF you can define the look of an element directly, via its properties, or indirectly with a Template or Style. At its simplest a style is a combination of property settings that can be applied to a UI element with a single property attribute. Templates are a mechanism for defining alternate UI for portions of your WPF application. There are several template types available in WPF (ControlTemplate, DataTemplate, HierarchicalDataTemplate and ItemsPanelTemplate).