Tuesday, August 10, 2010

Introduction to Windows Presentation Foundation (WPF)

Windows Presentation Foundation

Windows Presentation Foundation (WPF) is the successor of Windows Forms for desktop application development. WPF applications differ from traditional Windows Forms applications in several ways. The most notable is that the code for the user interface is separate from the code for application functionality. The user interface of a WPF application is typically defined using a relatively new declarative syntax called Extensible Application Markup Language (XAML).

Selecting an Application Type

WPF development supports three kinds of application: Windows applications, Navigation applications, and XAML Browser Applications (XBAP).

Windows applications are Microsoft Windows-driven and provide a user experience that is familiar to Windows users and developers alike. Multiple windows can be open at any given time, and there is built in sense of navigation or history.

Navigation applications provide a page based user experience, similar to the experience of using a Web site. Typically, only a single page can be open at any given time, and the journal functionality keeps a record of pages visited and allows back-and-fourth navigation. Unlike a Web site, however, a Navigation application is a compiled application, has full access to the resources of your computer.

XABPs are similar to Navigation applications, but they are designed to run in Windows Internet Explorer. These applications can be deployed to a server or to a Web site and are downloaded when instantiated. Applications of this type do not have full access to a computer’s resources. XBAPs run under partial-trust environment, and resources such as the file system and the registry are inaccessible by XBAPs.

Windows Applications

A Windows Application consists of one or more windows and the associated business logic. The top level user interface (UI) element of a window is a class that derives from the Window class. The Window class derives from ContentControl, meaning that it can contain a single element in its Content property. This element is usually a layout control, such as a Grid control, which can itself contain multiple child controls.

Navigation Application

Navigation applications allow you to provide a different style of user interface to users. A navigation application is a desktop application that uses Page objects as its primary object instead of Window objects. Like Window objects, Page objects can contain a single control.

Page-based navigation applications are hosted automatically in a Navigation Window at startup. The Navigation Window provides some built in functionality for navigating through the pages of an application, such as Back and Forward buttons, and the journal, which keeps track of the pages that have been visited recently.


XBAPs are similar to Navigation applications. They use Page objects as the top-level UI object, and they allow a page-based navigation model that is similar to the experience of using a Web page. The primary difference between XNAP and a Navigation application is that XBAPs are not installed. They are designed to run in Internet Explorer and do not require the user to copy them onto the hard drive.

You cannot perform the following actions in an XBAP

• Access the file system, except for isolated storage

• Access the registry

• Create stand-alone windows, such as dialog boxes.

• Access local databases

• Use Windows drag-and-drop functionality

• Use WCF Web services.

No comments: