WPF: An Introduction (Part 2)


Back to Part 1

ADVANTAGES & DISADVANTAGES OF WPF:

Advantages:

  • Tight multimedia integration - to use 3-D graphics, video, speech, and rich document viewing in Windows 32 or Windows Forms applications, you would need to learn several independent technologies and blend them together without much built-in support. WPF applications allow you to use all these features with a consistent programming model.
  • Resolution independence - WPF lets you shrink or enlarge elements on the screen, independent of the screen's resolution. It uses vector graphics to make your applications resolution-independent.
  • Hardware acceleration - WPF is built on top of Direct3D, which offloads work to graphics processing units (GPUs) instead of central processor units (CPUs). This provides WPF applications with the benefit of hardware acceleration, permitting smoother graphics and enhanced performance.
  • Declarative programming - WPF uses Extensible Application Markup Language (XAML) declarative programming to define the layout of application objects and to represent 3-D models, among other things. This allows graphic designers to directly contribute to the look and feel of WPF applications.
  • Rich composition and customization - WPF controls are easily customizable. You need not write any code to customize controls in very unique ways. WPF also lets you create skins for applications that have radically different looks.
  • Easy deployment - WPF provides options for deploying traditional Windows applications (using Windows Installer or Click Once). This feature is not unique to WPF, but is still an important component of the technology.
  • Culturally aware controls - static text in controls and the return data for the String function are modified according to the culture and language specified by the end user's operating system.

Disadvantages:
  • WPF's in-box control suite is far more limited than that of WinForms.
  • 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).
  • Most developers already know WinForms; WPF provides a new learning curve
  • WPF will not run on windows 2000 or lower.
  • No MDI child mode.

WPF TOOLS:
  1. Microsoft Visual Studio: is a developer-oriented IDE that contains a combination of XAML editor and WPF visual designer, beginning with Visual Studio 2008. The WPF designer add-in, codenamed Cider, is a WYSIWYG editor for creating WPF windows, pages and user controls. It was available earlier as Visual Studio 2005 extensions for .NET Framework 3.0 CTP for the initial release of WPF but is no longer available.
     
  2. Microsoft Visual Studio Express 2008 and later editions, particularly Visual C# Express and Visual Basic Express, also have the WPF designer integrated.
     
  3. Microsoft Expression Blend: is a designer-oriented tool that provides an art board for the creation of WPF applications with 2D and 3D graphics, text and forms content. It generates XAML that may be exported into other tools and shares solution (sln files) and project formats (csproj, vbproj) with Microsoft Visual Studio.
     
  4. Microsoft Expression Design: is a bitmap and 2D-vector graphics tool that allows export to XAML.
  5. XAMLPad: is a lightweight tool included in the .NET Framework SDK. It can create and render XAML files using a split screen UI layout. It also provides a tree view of the markup in a panel.

WPF ASSEMBLIES AND NAMESPACES:

Primary assemblies:
  • PresentationCore
  • PresentationFramework
  • WindowsBase

Namespaces
  • System.Windows

    All child namespaces except System.Windows.Forms

CLASS HIERARCHY OF WPF:

WPF2.gif

WPF ARCHITECTURE:

WPF3.gif

In this architecture these three Assemblies can be categorized as:
  • Managed Layer
  • Unmanaged Layer
  • Core API

MANAGED LAYER:

Windows Presentation Foundation (WPF) managed layer is a set of classes and types that are built using the .NET Framework which means that it is managed by Common Language Runtime (CLR). In this layer there are three assemblies that comprise the WPF framework:
  1. PresentationFramework.dll: Creates the High level elements like layout panels, controls, windows, styles etc.
     
  2. PresentationCore.dll: It holds base types such as UIElement, Visual from which all shapes and controls are derived in PresentationFramework.dll.
     
  3. WindowsBase.dll: They hold even more basic elements which are capable to be used outside the WPF environment like Dispatcher object, Dependency Objects. I will discuss each of them later.

UNMANAGED LAYER
  1. Milcore.dll: The unmanaged layer of WPF is called milcore or 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.
     
  2. 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.
  • Direct3D: It is the low level API in which the graphics of WPF is rendered.
     
  • User32: It is the primary core API which every program uses. It actually manages memory and process separation.
     
  • 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.

DIFFERENCE BETWEEN WPF AND SILVERLIGHT

Silverlight and Windows Presentation Foundation (WPF) are 2 different products from Microsoft, but have lot of overlap. Silverlight is a subset of WPF in terms of features and functionality. Silverlight was of course known as WPF/E where E means everywhere. Both use XAML, a form of XML to define controls but WPF is purely for windows while Silverlight runs in the browser on Windows and Macs. So, here are the differences between WPF and Silverlight:
  1. Silverlight is meant to be used online, while WPF is for local use.
  2. Silverlight lacks access to local resources, while WPF can utilize local resources.
  3. Silverlight only has perspective 3D support, while WPF is capable of full 3D images.
  4. Silverlight does not support some of the more advanced concepts of WPF such as controls and templating.
  5. Silverlight integrates right into an HTML page whereas WPF XAML files have to be loaded via a frame if they want to mix with HTML content.