Windows Presentation Foundation
From Wikipedia, the free encyclopedia
The Windows Presentation Foundation (or WPF), formerly code named Avalon, is the graphical subsystem feature of the .NET Framework 3.0 (formerly called WinFX)[1] and is directly related to XAML.[2] It is pre-installed in Vista,[3] the latest version of the Microsoft Windows operating system. WPF is also available for installation on Windows XP SP2 and Windows Server 2003. It provides a consistent programming model for building applications and provides a clear separation between the UI and the business logic. A WPF application can be deployed on the desktop or hosted in a web browser. It also enables richer control, design, and development of the visual aspects of Windows programs. It aims to unify a host of application services: user interface, 2D and 3D drawing, fixed and adaptive documents, vector graphics, raster graphics, animation, data binding, audio and video.
WPF/E is a subset of WPF, and stands for "Windows Presentation Foundation Everywhere". It is basically a mobile version of WPF, based on XAML and Javascript. 3D features are not included, but XPS, vector-based drawing and hardware acceleration are.
Contents |
[edit] Features
This article is part of the Windows Vista series. |
New features |
Overview |
Technical and core system |
Security and safety |
Management and administration |
Removed features |
Other articles |
Editions and pricing |
Development history |
Criticism |
List of Windows Vista topics |
The following is a partial list of WPF features.
[edit] Graphical Services
- All graphics (including desktop items like windows) will be routed through Direct3D.
- This aims to provide a unified avenue for displaying graphics, as well as more advanced graphical features.
- Routing the graphics through Direct3D will allow Windows to offload graphics tasks to the Graphics Processing Unit found on the computer's graphics card. This will reduce the workload on the computer's Central processing unit.
- Supports vector-based graphics, which allow infinite lossless scaling.
- Supports 3D model rendering and interaction in 2D Applications.
[edit] Deployment
- WPF isn't just for building traditional standalone applications. Its deployment model offers both standalone and XAML Browser Applications (XBAP) flavors. The programming model for building either flavor of application is similar.
- Standalone applications are those that have been locally installed on the computer using software such as ClickOnce or Microsoft Installer (MSI). Standalone applications are considered full trust and have full access to a computer's resources.
- XAML Browser Applications (XBAP's) are programs that are hosted inside a web browser such as Internet Explorer. Hosted applications run in a partial trust sandbox environment, and are not given full access to the computer's resources and not all WPF functionality is available. The hosted environment is intended to protect the computer from malicious applications. Starting an XBAP (pronounced "ex-bap") from an HTML page or vice versa is seamless (there is no security or installation prompt). Although one gets the perception of the application running in the browser it actually runs in an out of process exe different from the browser.
[edit] Interoperability
- WPF provides interoperability with Win32: Via hosting, one can use Windows Presentation Foundation inside existing Win32 code, or one can use existing Win32 code inside Windows Presentation Foundation.[4]
- Interoperability with Windows Forms is also possible through the use of the
ElementHost
andWindowsFormsHost
classes.
[edit] Media Services
- WPF provides shape primitives for 2D graphics along with a built-in set of brushes, pens, geometries, and transforms.
- The 3D capabilities in WPF are a subset of the full featureset provided by Direct3D. However, WPF provides tighter integration with other features like user interface (UI), documents, and media. This makes it possible to have 3D UI, 3D documents, and 3D media.
- There is support for most common image formats.
- WPF supports the video formats WMV, MPEG and some AVI files.
- WPF supports time-based animations, in contrast to the frame-based approach. This delinks the speed of the animation from how the system is performing.
- Text rendering is supported using ClearType. This provides for sub-pixel positioning, natural advance widths, and Y-direction anti-aliasing. WPF also supports OpenType font features.
[edit] Data Binding
- WPF has a built-in set of data services to enable application developers to bind and manipulate data within applications. There exists support for three types of data binding:
- one time: where the client ignores updates on the server
- one way: where the client has read-only access to data
- two way: where client can read from and write data to the server
- Binding of data has no bearing on its presentation. WPF provides data templates to control presentation of data.
[edit] User Interface
- A set of built-in controls is provided as part of WPF, containing items such as button, menu, and list box. Lacks a DataGrid control but 3rd-party vendors are already offering some.
- A powerful concept in the WPF is the logical separation of a control from its appearance.
- A control's template can be overridden to completely change its visual appearance.
- A control can contain any other control or layout, allowing for unprecedented control over composition.
[edit] Annotations
[edit] Imaging
Windows Imaging Component (WIC) for WPF will allow developers to write image codecs for their specific image file formats.
[edit] Effects
- WPF provides for bitmap effects, however, they are rendered in software. GPU features like pixel shaders are not used for bitmap effects.
- Special effects such as dropshadows and blurring are built in.
- Other effects such as reflections can be easily implemented.
[edit] Text
WPF includes a number of text rendering features that were not available in GDI. This is the first Windows programming interface to expose OpenType features to software developers, supporting both OpenType, TrueType, and OpenType CFF (Compact Font Format) fonts.
Support for OpenType includes:
- Ligatures
- Old-style numerals (for example, parts of the glyph hang below the text baseline)
- Swash variants
- Fractions
- Superscript and Subscript
- Small caps
Other typography features provided by WPF include line-level justification and Ruby characters.
WPF text rendering takes advantage of advances in ClearType technology, such as sub-pixel positioning, y-direction anti-aliasing, hardware-accelerated text rendering, as well as aggressive caching of pre-rendered text in video memory.[5] The extent to which this is supported is dependent on the video card. DirectX 10 cards will be able to cache the font glyphs in video memory, then perform the composition (assembling of character glyphs in the correct order, with the correct spacing), alpha-blending (application of anti-aliasing), and RGB blending (ClearType's sub-pixel color calculations), entirely in hardware. This means that only the original glyphs need to be stored in video memory once per font (Microsoft estimates that this would require 2MB of video memory per font), and other operations such as the display of anti-aliased text on top of other graphics – including video – can also be done with no computation effort on the part of the CPU. DirectX 9 cards are only able to cache the alpha-blended glyphs in memory, thus requiring the CPU to handle glyph composition and alpha-blending before passing this to the video card. Caching these partially-rendered glyphs requires significantly more memory (Microsoft estimates 5MB per process). Cards that don't support DirectX 9 have no hardware-accelerated text rendering capabilities. ClearType font smoothing however cannot be optionally turned off.
Animated text is also supported; this refers to animated glyphs, as well as real-time changes in position, size, color, and opacity of the text.
[edit] Alternative Input
WPF supports tablet/digital ink-related functionality.
[edit] Accessibility
WPF supports UI Automation to allow developers to create accessible interfaces.
[edit] XAML
Following the success of markup languages for web development, WPF introduces a new language known as eXtensible Application Markup Language (XAML), which is based on XML. It is meant to be a faster way to develop application user interfaces and a better way for designers and developers to collaborate. Using XAML to develop user interfaces also allows for separation of model and view; this is generally considered a good architectural principle. In XAML, every element maps onto a class in the underlying API, and the attributes are set as properties on the instantiated classes. As in web development, both layouts and specific themes are well suited to markup, but XAML is not required for either. Indeed, all elements of WPF may be coded in a .NET language (C#, VB.net). The XAML code is ultimately compiled into a managed assembly in the same way all .NET languages are, which means that the use of XAML for development does not incur a performance cost.
It is likely that many applications, such as Microsoft PowerPoint and Word, will support exporting their content to WPF through a XAML representation.
There are several subset (or profiles) of XAML, such as:
- XAML Presentation (XAML-P) - incorporates all items encompassing WPF v1.0
- XML Paper Specification (XPS) - a subset of XAML-P for representing fixed format documents and used as the spool format for the printing subsystem in Windows Vista
There are also profiles specific to Workflow Foundation, and other domain specific subsets will likely emerge in the future.
[edit] Tools
There are a number of development tools available for developing Windows Presentation Foundation applications, most currently of beta quality, some commercially released.
- Microsoft Cider is an add-in for the Visual Studio 2005 designer for building Windows Presentation Foundation applications. Meant to be used by application developers.
- Microsoft Expression Blend is a designer-oriented tool that provides a canvas 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.
- Microsoft Expression Design is a bitmap and 2D-vector graphics tool that allows export to XAML.
- Electric Rain ZAM 3D provides an interactive graphical design environment for constructing 3D models that can be exported into XAML.
- Mobiform Aurora provides an alternative tool for constructing WPF user interfaces.
- Xceed DataGrid for WPF free full-featured DataGrid control for WPF.
[edit] WPF/E
Windows Presentation Foundation/Everywhere is a cross platform XAML-based WPF technology[6] that provides features such as video, vector graphics, and animations to multiple operating systems including Windows Vista, Windows XP, and Mac OS X. Specifically, WPF/E is provided as an add-on for Mozilla Firefox, Internet Explorer 6 and above, and Apple Safari. WPF/E and WPF only share XAML presentation layer.
These extensions will allow browsers to use WPF/E graphics capabilities. The browser extensions will be similar to Adobe Flash, a highly popular graphic plug-in available for most browsers. Internet Explorer will have native support for WPF in Windows Vista, and will support WPF/E in older versions.
WPF/E will work in concert with XAML and will be scriptable with JavaScript. Version 2.0 will also contain a version of the Common Language Runtime so it can execute VB.Net and C# code in a sandbox with no local file access.
Commonly mentioned as alternatives to WPF/E are Adobe Flex, Nexaweb, OpenLaszlo, and Ajax.
The first CTP of WPF/E was released in December 2006. Microsoft aims to have a final release by mid-2007.
[edit] WPF Applications
WPF is intended to be the next-generation graphics API for Windows applications on the desktop. Applications written in WPF are visually of a higher quality. The following are some of Microsoft's own products or other third-party mainstream applications written in WPF:
- Microsoft Expression Design
- Microsoft Expression Blend
- Yahoo! Messenger
- New York Times Reader
[edit] References
- ^ MSDN .NET Framework: Windows Presentation Foundation
- ^ MSDN .NET Development: WPF : XAML Overview
- ^ Windows Vista: Windows Presentation Foundation (Avalon) FAQ
- ^ WPF and Win32 Interoperation Overview
- ^ MSDN Library : .NET Development : WPF : ClearType Overview
- ^ ASP.NET : WPF/E - December 2006 Community Technology Preview
[edit] See also
[edit] External links
- The Windows Presentation Foundation community portal -- The WPF section of the .NET Framework 3.0 community site.
- MSDN Windows Presentation Foundation SDK -- Software Development Kit for WPF.
- WPFwiki.org -- The largest WPF FAQ question and answer repository & Wiki.
- Getting Started (WPF) -- Roadmap to information for developers new to WPF.
- WPF SDK Blog -- Active blog maintained by the WPF SDK team.
- Windows Presentation Foundation Unleashed -- The first WPF book to market, written by the lead developers Adam Nathan.
- Essential Windows Presentation Foundation -- An online WPF tutorial and reference, written by Chris Anderson.
- Microsoft Expression Blend -- Visual tool for creating Windows Presentation Foundation applications.
- wpf made simple -- Provides info/samples on WPF.
- XAML.net Information on XAML and XBAPs, the Windows Presentation Foundation (WPF), .NET Framework 3.0 and Windows Vista]].
- A Guided Tour of Windows Presentation Foundation -- Microsoft's overview of Windows Presentation Foundation.
- Windows Presentation Foundation Security Sandbox -- An overview of the sandbox in which WPF browser applications run.
- MSDN Forums for Windows Presentation Foundation -- Active discussion forum for WPF developers.
- WPF/E Google Group -- Discussion group and list of examples.
- Microsoft goes cross-platform with WPF/E -- WPF/E explained in an interview with Microsoft's Director of Developer Tools.
- More than meets the eye in Microsoft's plans -- News.com's article on WPF/E
- WPF page on NetFXGuide.com
- A Five Mile Overview of WPF -- A high-level overview of WPF for software developers.
- xbap.org -- Comprehensive information on XBAP applications.
- DirectX 10 Wiki - Wiki covering WPF and DirectX 10 Tutorials, Samples, Effect, News.
Architecture: | Common Language Infrastructure • .NET assembly • .NET metadata • Base Class Library |
Common Language Infrastructure: | Common Language Runtime • Common Type System • Common Intermediate Language • Virtual Execution System |
Languages: | C# • Visual Basic .NET • C++/CLI (Managed) • J# • JScript .NET • Windows PowerShell • IronPython • F# |
Windows Foundations: | Presentation • Communication • Workflow • CardSpace |
Related: | Windows Forms • ASP.NET • ADO.NET • .NET Remoting • XAML |
Other Implementations: | .NET Compact Framework • .NET Micro Framework • Shared Source CLI • Portable.NET • Mono |
Comparison: | C# vs. Java • C# vs. VB.NET |