Thursday, June 17, 2010

WPF 4.0

Windows Presentation Framework (WPF), as we all know help us to design and build rich UI applications. Considering the requirements of rich UI, Microsoft has concentrated in the areas of improving performance and providing new controls besides providing support for multitouch and other Windows 7 features. In WPF 4.0 , there are new controls, XAML changes, Text, Graphics, Windows 7 integration (multitouch, taskbar integration, etc), Core Fundamentals, and Deployment. So, to get the best out of WPF 4.0, you would need Windows 7. Lets talk about all these one by one.

New Controls: Datagrid, Datepicker , Calender, Office Ribbon Control
All these controls were originally part of .Net Framework 3.5 SP1 or better known as WPFToolkit. Being the succeeding version, all these controls are now directly available in .Net Framework 4.0.

Visual State Manager
In previous versions of WPF, you could not manage states of controls like button through ControlTemplate, but you had to do them through triggers. However in WPF 4.0, your life will become easier and it would be possible to do the same by defining the behavior in the template(ControlTemplate).

Multitouch
All controls in WPF now accept touch input. Classes like UIElement, and UIElement3D, and ContentElement now expose events that occur when a user touches an element on a touch-enabled screen. In addition to the touch events, the UIElement supports manipulation.

Text, Animation and Graphics Enhancements
There are several enhancement and introduction of new functions to support easier and efficient graphics and animations. a few such examples are Layout Rounding, Cached Composition, Pixel Shader 3 (enhanced version of PS 2.0 in SP1) and Easing Functions etc.Besides this text rendering features have been revamped from root.

Windows 7 Shell Integration
WPF 4.0 has several new and key Windows 7 Shell features . These Shell features enable a richer, integrated user experience. The new taskbar is less cluttered and can convey more information at a glance. The aero thumbnails support user commands. Jump lists provide access to contextual startup tasks and files available to the application.

XAML / BAML Enhancements
Two features have been added to XAML browser applications.
HTML-XBAP Script & Full-Trust XBAP Deployment.

Easier Object References
Now referencing objects in XAML is not only easier to use but better in performance by using tags x:reference. {x:reference} markup extension tag can replace the traditional Binding tag in most cases.

Easier Built in Type References
Besides this in XAML you can now directly refer to built in types. For example <sys:String xmlns:sys="clr-namespace:System;assembly=mscorlib >text</sys:String> can be replaced with <x:String>text</x:String>


Support For Generics in XAML
Now you will be able to define the type of Generic object directly in XAML by using x:TypeArguments extension markup.

Support For Use of Static Factory Methods in XAML
Now with x:FactoryMethod extension markup, you can call static methods directly in XAML. Example <Guid x:FactoryMethod="Guid.NewGuid" />