Wednesday, July 20, 2011

What is Windows Presentation Foundation

The Windows Presentation Foundation is Microsoft’s next generation UI framework to create applications with a rich user experience. It is part of the .NET framework 3.0 and higher.

  • WPF is also known as ”AVALON”.
  • WPF supports Rich User interface programming.
  • WPF supports :-
    1. To work with colors.
    2. To work with transformations.
    3. To develop Animations.
    4. To work with Brushes etc…
  • WPF puts forward a new set of classes and assemblies which allows us to write programs more efficiently and flexibly.
  • WPF combines application UI’s,2D graphics,3D graphics, documents and multimedia into one single framework. This makes UI faster, scalable and resolution independent.

Types of Tools

  • Microsoft provides two development tools for WPF applications.

1. Visual Studio. ( For Developers)

2. Expression Blend. ( For Designers )

  • Visual studio is the tool for developers to develop WPF and is good in code & XAML editing. It has a rare support for all the graphical stuff like gradients, template editing, animation etc.
  • Expression Blend is the tool for designers, that covers the graphical part very well but it has (still) rare support for code & XAML editing.

ARCHITECTURE of WPF


WPF is actually a set of assemblies that build up the entire framework. These assemblies can be categorized as

  • Managed Layer
  • UnManaged Layer
  • Core API
  1. Managed Layer : Managed layer of WPF is built using a number of assemblies. These assemblies build up the WPF framework, communicates with lower level unmanaged API to render its content. The few assemblies that comprise the WPF framework are :
    • PresentationFramework.dll : Creates the top level elements like layout panels, controls, windows, styles etc.
    • PresentationCore.dll : It holds base types such as UIElement, Visual from which all shapes and controls are Derived in PresentationFramework.dll. 
    • WindowsBase.dll : They hold even more basic elements which are capable to be used outside the WPF environment like Dispatcher object, Dependency Objects. 
  2. Unmanaged Layer (milcore.dll):  The unmanaged layer of WPF is called milcore / Media Integration Library Core. It basically translates the WPF higher level objects like layout panels, buttons, animation etc into textures that Direct3D expects.  It is the main rendering engine of WPF.
    • WindowsCodecs.dll : This is another low level API which is used for imaging support in WPF applications. WindowsCodecs.dll comprises of a number of codecs which encodes / decodes images into vector graphics that would be rendered into WPF screen.
  3. Direct3D : It is the low level API in which the graphics of WPF is rendered.
  4. User32 : It is the primary core API which every program uses. It actually manages memory and process separation.
  5. GDI & Device Drivers : GDI and Device Drivers are specific to the operating system which is also used from the application to access low level APIs.

XAML

  • XAML stands for Extensible Application Markup Language.
  • Its a simple language based on XML to create and initialize .NET objects with hierarchical relations.
  • XAML is a case-sensitive and also called as Structured language.
  • XAML is  a collection of predefined tags.

Advantages of XAML

  • XAML code is short and clear to read.
  • Separation of designer code and logic.
  • Graphical design tools like Expression Blend require XAML as source.
  • The separation of XAML and UI logic allows it to clearly separate the roles of designer and developer.

Namespaces of XAML

The mapping between an XML namespace and a CLR namespace is done by the XmlnsDefinition attribute at assembly level. You can also directly include a CLR namespace in XAML by using the clr-namespace: prefix.

Disadavantages of WPF

  1. WPF's in-box control suite is far more limited than that of WinForms.
  2.  There's greater support in the 3rd-party control space for WinForms. (That's changing, but for now by advantage of time, WinForms has greater support in the community.
  3. Most developers already know WinForms; WPF provides  a new learning curve.

WPF will not run on windows 2000 or lower.

Below are the differences between WPF & WINFORMS.

WPF (VS) WINFORMS

WPF

+ Powerful styling and skinning structure

+ Easy to create an own Look and Feel

+ Does support Windows Forms

+ The future technology for developing Vista Applications

+ The ability to reuse existing code

+ Highly advanced data binding possible

- Declarative vs. procedural code

- Requires .NET Framework 3.0

- Compared to Windows Forms, still in development phase

- Requires Dx9 compatible vidcard for advanced graphics

Windows Form

+ Extensive documentation to be found on the internet

+ Plenty of examples

+ Does support WPF

- How long will this be supported? (I've read somewhere that Microsoft is only developing WPF now, only maintenance for Winforms)

- Design your own look and feel in a application is a lot of work.

What is Windows Presentation Foundation

The Windows Presentation Foundation is Microsoft’s next generation UI framework to create applications with a rich user experience. It is ...