AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=1529&pId=-1
Introducing Windows Presentation Foundation (WPF)
page
by Rajdeep Mukherjee
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 29499/ 76

Overview

User Interfaces in any software application are an extremely important aspect of any programming model. Designing effective user interfaces gives measurable benefits to the users of the software to whom it's intended.  The objective of Windows Presentation Foundation (WPF) is to provide developers with an effective tool to design and develop attractive, effective user interfaces. WPF helps to create dynamic, data driven presentation systems.  It also provides a common programming model for browser based and standalone applications. The objective of this article is to provide an introduction of WPF to the readers who are new to this technology and to present its important features.

What is Windows Presentation Foundation?

Windows Presentation Foundation, code name Avalon, is a graphical subsystem feature of the .NET Framework 3.0 and comes as a built in package with Microsoft Windows Vista operating system. WPF can also be installed with other popular Windows operating systems like Windows XP SP2 and Windows Server 2003. The objective is to present a steady programming model for applications with isolation between User Interfaces and Business Logic layers. A WPF application is mostly web based but it can also be implemented on a desktop environment. The visual aspects of Windows based programming that expects rich graphics, controls design and development, are well handled by WPF. Many application services like User Interface, fixed documents, adaptive documents, 2D and 3D drawings, animation, audio, video etc. work together in unison under WPF. Microsoft Silverlight that is based on XAML and JScript is a web based subset of WPF. Silverlight helps develop web and mobile applications with codes similar to .NET applications and the applications are similar to Flash.

WPF allows developers to create applications that are friendly and rich in quality to the target users. Developers can use WPF in building applications similar to building applications on Win32 and DHTML based applications and content. Unlike being a typical tool for only developing enhanced graphics, WPF takes care of all forms of presentations like User Interface, media, vector graphics, and documents that can be looked as a novelty in the Windows platform.   

WPF and XAML

WPF reduces the amount of procedural code in application specifications and enables increased collaboration amongst various team members in the development team and in turn, rationalizes the development process. XAML is the new technology from Microsoft that drives this union between design and implementation. XAML is a declarative mark up language based on XML and is used in initializing structured values and objects. The acronym stands for Extensible Application Markup Language. XAML is designed as an enhanced method of developing application user interfaces and is used extensively in the .NET Framework 3.0 technologies, mostly in WPF. XAML helps create graphically rich visual User Interfaces (similar to the ones created by Adobe Flash, UIML etc.) when used in WPF. WPF supports various features like 2D and 3D objects, animations, rotations, and various other effects.

The XAML advantage to WPF goes to its declarative nature that allows developers to describe the behavior and integration of components without using procedural programming. This helps a developer to create a working application even without much knowledge of procedural programming. This case however is rare where an entire application is developed on XAML, but in practical scenarios, XAML enables the designers to more effectively contribute during any application's development. XAML, however, is not specific to WPF or .NET and the standard is in use by other technologies too.

 

How WPF works

This section provides a brief description of the architecture of WPF which spreads across both managed code and native code components. The managed code only provides the publicly exposed API. The major code portions of WPF are the PresentationFramework, PresentationCore, and milcore. The composition engine of WPF is a native component and is known as MIL (Media Integration Layer) and resides in the milcore.dll. Milcore is written in unmanaged code and the interfacing is done with DirectX at this level for providing support for 2D and 3D surfaces. WPF displays are done through the DirectX engine. The composition engine in WPF is highly performance sensitive and demands forsaking of several CLR advantages for enhancing performance.  PresentationCore (presentationcore.dll) implements the core services for WPF and the PresentationFramework (presentationframework.dll) is responsible for the presentation features of the end users. The major WPF subsystems are as follows; Object, Threading.DispatcherObject, Windows.DependancyObject, Windows.Media.Visual, Windows.UIElement, Windows.FrameworkElement, Windows.Controls.Control. Details of the WPF architecture are beyond the scope of this article.

Features

This section provides some salient features of the WPF.

1.      WPF offers all graphics as Direct3D applications. Direct 3D applications are supported by Microsoft Windows Operating Systems and are part of Microsoft’s DirectX API. This is primarily used to render three dimensional graphics in performance savvy applications (e.g. games).

2.      Interoperability with Win32 is supported by WPF. Windows Presentation Foundation can be used internally to Win32 pre-existing code through hosting and at the same time, Win32 code can be used inside WPF. ElementHost and WindowsFormsHost classes can be used to enable interoperability of WPF with Windows Forms. 

3.      WPF provides a built-in set of brushes, pens and geometries and also provides shape primitives for 2D graphics. The WPF 3D features are just a subset of the Direct3D feature set. Additionally, WPF provides better integration with User Interfaces, documents and media. This way it provides 3D UI, media and documents.

4.      WPF supports all the standard image formats and video formats like WMV, MPEG and AVI. WPF also supports time based animations, Open Type Font features and Text rendering.

5.      WPF supports time based animations. These animation effects can be defined object wise and can be directly accessed from XAML markup. Animations can also be activated by external events like user action. WPF comes with a set of built-in effects that may be used readily by the designers.

6.      Developers with the help of WPF can write image codecs for their specific image file formats. This happens due to the fact that Windows Imaging Component codecs and APIs can be locally used by WPF.

7.      WPF supports XML Paper Specification documents. It also supports reading and writing of paginated documents.

8.      WPF offers many built-in controls like button, list box etc. There is a significant aspect to be considered for WPF and that is the logical separation of a control from its appearance. The visual appearance of any control can be changed by modifying the corresponding control template. A control may have any other control or layout and this enables excellent control on the composition.

9.      WPF offers some useful, built-in effects such as bitmap effects, special effects like dropshadows and blurring, etc. Other special effects can also be easily implemented by WPF.

10.  Binding and manipulation of application data is supported by WPF through its built-in set of data services. Data templates for controlling data presentation are also provided by WPF.

Suggested Readings
Conclusion

Windows Presentation Foundation is an essential change from how Windows allowed the working of interactive applications earlier. In this article we have introduced WPF to the beginners and illustrated its salient features. However, there are loads of things to learn about WPF to effectively use this new technology from Microsoft. It is recommended for beginners who are new to this technology to read more on WPF before getting started apart from this article, and in this regard, few tutorials links are also provided as references. WPF from Microsoft aims to stand tall amidst various competitions and criticisms in the creative development community and we expect greater offerings from Microsoft in this area in the near future.



©Copyright 1998-2021 ASPAlliance.com  |  Page Processed at 2021-04-16 10:57:51 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search