dotted banner right

What is WPF?

Windows Presentation Foundation (or WPF) is a graphical subsystem for rendering user interfaces in Windows-based applications by Microsoft. WPF, previously known as “Avalon”. WPF employs XAML, an XML-based language, to define and link various interface elements. WPF applications can also be deployed as standalone desktop programs, or hosted as an embedded object in a website.

Why WPF

WPF aims to unify a number of common user interface elements, such as 2D/3D rendering, fixed and adaptive documents, typography, vector graphics, runtime animation, and pre-rendered media. These elements can then be linked and manipulated based on various events, user interactions, and data bindings. WPF uses DirectX. WPF attempts to provide a consistent programming model for building applications and separates the user interface from business logic. It resembles similar XML-oriented object models, such as those implemented in XUL and SVG.

Features

Direct3D

By using Direct 3D, Graphics that includes desktop items like windows are rendered. Thereby allowing the display of custom themes and complex graphics, at the cost of a wider range of support of GDI and uniform control theming. It allows Windows to offload some graphics tasks to the GPU. This decreases the workload on the CPU. GPUs are optimized for parallel pixel computations. This tends to speed up screen refreshes at the cost of decreased compatibility in markets where GPUs are not necessarily much powerful, such as the netbook market. The Windows Presentation Foundation (WPF) is Microsoft’s UI framework to create applications with a great user experience. WPF is a fragment of the .NET framework 3.0 and higher. WPF emphasis on vector graphics that allows most controls and elements to be scaled without loss in quality or pixels, thus increasing its accessibility. With the exception of Silverlight, Direct3D integration allows for streamlined 3D rendering. In addition, interactive 2D content can be covered on 3D surfaces natively.

Data binding

WPF contains built-in sets of data services that are responsible for enabling application developers. This is done to bind and manipulate data within the applications.
It supports four types of data binding, these are:

  • One time: In this type of data binding the client ignores updates on the server.
  • One way: In one way data binding, the client has read-only access to data.
  • Two ways: Here clients can read from and write data to the server
  • One way to source: In this the client has write-only access to data

LINQ queries for data binding (including LINQ to XML) can also behave as data sources. Data binding has no bearing on its presentation. To control the presentation of data, WPF provides data templates.

Media services

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

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

Control Templates

Underlying all UI controls in WPF is a new composition model. Every control is composed of one or more ‘visuals’. These visual sub-elements turn into a hierarchical Visual Tree by WPF and eventually rendered by the GPU. Because WPF controls are not wrappers for standard Windows controls their UI can be radically changed without affecting the normal behavior of the control. Every control in WPF has a default ‘template’ that defines its visual tree. The default template is created by the control author and is replaceable by other developers and designers. The substitute UI is placed within a ControlTemplate.

Data Templates

WPF has a flexible data binding system. UI elements can be populated and synchronized with data from an underlying data model. Rather than showing the simple text for the bound data WPF can apply a Data Template (replaceable UI for .NET types) before rendering to the Visual Tree.

Animations
In contrast to the frame-based approach, WPF supports time-based animations. This separates the speed of the animation from the way system is performing. WPF supports low level animation through timers. And higher level abstractions of animations through the Animation classes. Any WPF element property can be animated as long as it is registered as a Dependency Property. Animation classes are based on the .NET type of property to be animated. For instance, changing the color of an element is performed by the ColorAnimation class and animating the Width of an element (which is typed as a Double) is performed by the DoubleAnimation class.

Imaging

WPF can natively access Windows Imaging Component (WIC) code. APIs allows developers to write image codecs for their particular image file formats.

Effects

WPF 3.0 provides for Bitmap effects (BitmapEffect class), which are raster effects applied to a Visual. These raster effects are written in unmanaged code and force rendering of the Visual to be performed on the CPU and not hardware accelerated by the GPU. BitmapEffects were deprecated in .NET 3.5 SP 1.

Clients Love Us!