Contents

1 WHAT IS MICROSOFT WINDOWS PRESENTATION FOUNDATION:
2 Explanation:
2.1 N-Tier Application :
2.2 WPF & Other Presentation Technologies:
2.2.1 What WPF Provides?
2.3 Why we need it?
2.4 WPF is good for?
2.5 The Evolution of WPF:
2.5.1 WPF 3.0
2.5.2 WPF 3.5:
2.5.3 WPF 4.0:
2.6 New Features in WPF 3.5:
2.6.1 Firefox support for XBAPs.
2.6.2 Data binding support for LINQ.
2.6.3 Data binding support for IDataErrorInfo:
2.7 New Features in WPF 4.0:
2.7.1 New Controls
2.7.2 Visual State Manager
2.7.3 Windows 7 Multitouch Support
2.7.4 Graphics and Animations
2.7.5 New Text Rendering Stack
2.7.6 Custom Dictionaries
2.7.7 Selection and Caret Customization
2.7.8 Binding
2.8 XAML Browser Applications
2.8.1 HTML-XBAP Script Interop
2.8.2 Full-Trust XBAP Deployment
2.9 Understanding Windows Graphics:
2.10 DirectX: The new Graphic Engine:
2.11 The Class Hierarchy:
2.12 The core WPF namespaces:
2.12.1 System.Windows
2.12.2 System.Windows.Controls
2.12.3 System.Windows.Media
2.12.4 System.Threading.DispatcherObject
2.12.5 System.Windows.UIElement
2.12.6 System.Windows.FrameworkElement
2.12.7 System.Windows.Controls.ContentControl
2.12.8 System.Windows.Controls.ItemsControl
2.12.9 System.Windows.Controls.Panel
2.12.10 System.Windows.Shapes.Shape
2.12.11 System.Windows.Controls.Control
2.13 WPF TIERS:
2.13.1 Rendering Tier 0
2.13.2 Rendering Tier 1
2.13.3 Rendering Tier 2
2.14 WPF: A Higher-Level API:
2.14.1 A rich drawing model
2.14.2 A rich text model
2.14.3 Animation as a first-class programming concept
2.14.4 Support for audio and video media
2.14.5 Styles and templates
2.14.6 Commands
2.14.7 Declarative user interface:
2.14.8 Page-based applications
2.15 Resolution Independence:
2.16 Silverlight:
2.16.1 Silverlight 1.0
2.16.2 Silverlight 2.0
2.16.3 Silverlight 3.0
2.16.4 Silverlight 4.0
2.16.5 Silverlight 5
2.17 The Architecture of WPF:
2.17.1 Milcore.dll:
2.17.2 PresentationFramework.dll
2.17.3 PresentationCore.dll
2.17.4 WindowsBase.dll
2.17.5 Milcore.dll
2.17.6 User32
3 References
3.1 Book References


1 WHAT IS MICROSOFT WINDOWS PRESENTATION FOUNDATION:

Microsoft Windows Presentation Foundation (WPF) is an entirely new graphical display system developed by Microsoft for windows.

2 Explanation:

Windows Forms is a mature and full-featured toolkit, yet it can’t be so much customizable . Most significantly, Windows Forms relies on the Windows API to create the visual appearance of standard user interface elements such as buttons, text boxes, check boxes and so on. Because of relying on Windows API , we are not able to change beyond the provided specifications without going inner/low level details. 
WPF is a Most radical change in user interface since Windows 95. WPF provide powerful features with an ease. Designers and developers couldn’t work together before WPF.

Further details are provided below:

2.1  N-Tier Application :

As its name depicts its placement in an N-Tier application. WPF lies in  Presentation layer.




2.2 WPF & Other Presentation Technologies:

2.2.1 What WPF Provides?
     A unified platform for modern user interfaces



Tip:
 If you’ve done a large amount of work in Windows Forms application, you don’t need to migrate to get access to new features such as animation.
 You can add WPF content to your existing Windows Forms application.
Or you can create a WPF application that incorporates with Windows Forms content.

2.3 Why we need it?

 Although Windows Forms is a mature and full-featured toolkit but that haven’t changed much in the past ten years.
 Windows Forms relies on the Windows API to create the visual. As a result, these ingredients are essentially uncustomizable.
For example, if you want to create a stylish glow button you need to create a custom control and paint every aspect of the button (in all its different states) using a lower-level drawing model.
 Bitmap and Vector Graphics.
 Performance overhead that you suffered with Windows Forms.
 Problem for video files, animation and 3-D content.
 Designers and developers couldn’t work together.
 Problem in applications which scale to high resolution screens.

2.4 WPF is good for?

 Animated effects such as spinning text, shimmering buttons, shrinking windows, and live previews because you’ll have to paint every detail by hand.
 Restyle common controls such as buttons, often without writing any code.
 Transformation objects to rotate, stretch, scale, and skew anything in your user interface.
 A powerful new infrastructure based on DirectX, the hardware-accelerated graphics API that’s commonly used in cutting-edge computer games. This means that you can use rich graphical effects without any tension of performance overhead that you suffered with Windows Forms.
 Animation, and 3-D features.
 It’s just as easy to use common controls in WPF as it is in Windows Forms.
 Improved data binding model.
 A new set of classes for printing content and a document feature for displaying large amounts of formatted text.
 A new model for building page-based applications that runs in Internet Explorer and can be launched from a website.
 Providing common technology for Windows and web applications.

2.5 The Evolution of WPF:

  It already exists in three versions:

2.5.1   WPF 3.0

The first version of WPF with two other new technologies: WCF and WF. Together, these three technologies were called the .NET Framework 3.0

2.5.2  WPF 3.5:

A year later, a new version of WPF was released as part of the .NET Framework 3.5.
Refinements and bug fixes and performance improvements.
Difference between WPF 3.0 and 3.5 is design-time support.


2.5.3 WPF 4.0:

Ribbon control.
Rich Design time support.
refinements, better text rendering, more natural animation
support for Windows 7 features such as multitouch and the new taskbar


2.6 New Features in WPF 3.5:

2.6.1 Firefox support for XBAPs.


It’s now possible to run WPF browser-hosted applications (known as XBAPs) in Firefox as well as in Internet Explorer.

2.6.2  Data binding support for LINQ. 


 LINQ is a component of .NET Framework that allow developers to write queries. These  queries can pull data out of various data sources, including in-memory collections, XML files, and databases, all without requiring a line of low-level code. WPF now fully supports using  LINQ in data binding scenarios.

2.6.3 Data binding support for IDataErrorInfo:


Provides the functionality to offer custom error information that a user interface can bind to .
Support for placing interactive controls (such as buttons) inside a RichTextBox control.
Support for placing 2-D elements on 3-D surfaces.            
 An add-in model.
 Allows an application to host third-party components in a limited security context.

2.7 New Features in WPF 4.0:

2.7.1  New Controls


Three new controls (DataGrid, Calendar and DatePicker) have been added to WPF to make it easier to create business applications. These controls are almost 100 percent compatible with the Silverlight versions. This enables developers to reuse code and quickly create client and Web versions.

2.7.2 Visual State Manager

 WPF provides better support for changing visual states in a ControlTemplate. The VisualStateManager class and supporting classes have been added so that tools such as Microsoft Expression Blend can be used to define a control's appearance according to its visual state. For example, you can define the appearance of a Button control when it is in the Pressed state.

2.7.3 Windows 7 Multitouch Support

With the introduction of multi-touch input and manipulation processing support, WPF 4 provides a great way to light up your client applications in Windows 7. Multiple finger input are exposed through existing and new input events in WPF 4, while new manipulation and inertia events are now available for developers to use. New features include:
Multi-touch Manipulation, Inertia (Pan, Zoom, Rotate) events on UIElement
Raw multi-touch events (Up, Move, Down) on UIElement, UIElement3D and ContentElement
Multiple capture supporting multiple active controls
ScrollViewer enhancement to support multi-touch panning
Touch device extensibility

2.7.4 Graphics and Animations 

2.7.4.1 Layout Rounding


2.7.4.2 Cached Composition

By using the new BitmapCache and BitmapCacheBrush classes, you can cache a complex part of the visual tree as a bitmap and greatly improve rendering time. The bitmap remains responsive to user input, such as mouse clicks, and you can paint it onto other elements just like any brush.

2.7.4.3 Pixel Shader 3 Support

WPF 4 builds on top of the ShaderEffect support introduced in WPF 3.5 SP1 by allowing applications to now write effects by using Pixel Shader (PS) version 3.0. The PS 3.0 shader model is more sophisticated than PS 2.0, which allows for even more effects on supported hardware.

2.7.4.4 Easing Functions

You can enhance animations with easing functions, which give you additional control over the   behavior of animations. For example, you can apply an ElasticEase to an animation to give the animation a springy behavior (using System.Windows.Media.Animation namespace).

2.7.4.5 Text 

  Several changes have been made related to text.

2.7.5 New Text Rendering Stack

The WPF text rendering stack has been completely replaced. This change brings improvements to text rendering configurability, clarity, and support for international languages. The new text stack now supports explicitly selecting aliased, grayscale, or ClearType rendering modes. The text stack now supports display-optimized character layout, to produce text with sharpness comparable to Win32/GDI text. The new text stack allows optimizing text hinting and snapping for either animated or static text. The new text stack also supports fonts with embedded bitmaps to be substituted for smaller font sizes, allowing many East Asian fonts to   render with sharpness comparable to Win32/GDI text.

2.7.6 Custom Dictionaries

WPF includes a spell checker which before WPF 4 only used the OS-provided dictionary for input validation. This has been a major issue for apps which target specific industries with specialized terminology, as those apps were plagued by misspelling notifications. WPF 4 has introduced an API to allow an application to add words to the dictionaries used by WPF for spell checking

2.7.7 Selection and Caret Customization

You can now specify the brush that paints the selection and caret for input and reading controls, such as TextBox RichTextBox, and FlowDocumentReader. There are two new    properties on TextBoxBase:
SelectionBrush allows you to create a brush for highlighting selected text.
CaretBrush
allows you to change the brush that paints the cursor.

2.7.8 Binding

Various changes and enhancements have been made related to binding as supporting Bind to Dynamic Objects.

2.8 XAML Browser Applications

Two features have been added to XAML browser applications (XBAPs).

2.8.1 HTML-XBAP Script Interop


You can now communicate with the Web page containing the XBAP when the application is hosted in a HTML frame. The XBAP can get deep access to the HTML DOM and can handle DOM events.

2.8.2  Full-Trust XBAP Deployment

If your XBAP requires full trust, the user will now automatically receive the standard ClickOnce elevation prompt when they install the application from the intranet or one of their browser's trusted sites.

2.9 Understanding Windows Graphics:

A standard Windows application relies on two main parts of the Windows operating system to create its user interface:
User32 provides the familiar Windows look and feel for elements such as windows, buttons, text boxes, and so on.
GDI/GDI+ provides drawing support for rendering shapes, text, and images.
User32 and GDI/GDI+ was introduced more than 15 years ago and was well established in Windows 3.0.
Over the years, both technologies have been just refined.
But whether you’re crafting an application with .NET and Windows Forms, or in the past with Visual Basic 6 or MFC-based C++ code, behind the scenes the same parts of the Windows operating system are at work. Newer frameworks simply deliver better wrappers for interacting with User32 and GDI/GDI+.

2.10 DirectX: The new Graphic Engine:

Microsoft created the limitations of the User32 and GDI/GDI+ libraries.
DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia.
Its design purpose was speed, and so Microsoft worked closely with video card  for special effects such as partial transparency, and three-dimensional graphics.
 First introduced (shortly after Windows 95). DirectX has matured. It’s now an integral part of Windows, with support for all modern video cards.
In WPF, the underlying graphics technology is DirectX not GDI/GDI+.
WPF applications use DirectX no matter what type of user interface you create whether you’re designing complex three-dimensional graphics or just drawing buttons and plain text, all the drawing work travels through the DirectX.
DirectX hands off as much work as possible to the GPU (graphics processing unit), which is the dedicated processor on the video card.
Note: WPF still relies on User32 for certain services, such as handling and routing input and sorting out.
Note: WPF is not a wrapper for GDI/GDI+. Instead, it’s a replacement.

2.11 The Class Hierarchy:


2.12 The core WPF namespaces:
2.12.1 System.Windows
2.12.2 System.Windows.Controls
2.12.3 System.Windows.Media
2.12.4  System.Threading.DispatcherObject 


 All WPF objects derive from the DispatcherObject.

2.12.5 System.Windows.UIElement 


2.12.6 System.Windows.FrameworkElement 

 FrameWorkElement uses the foundation set by UIElement. It adds key properties like  HorizontalAlignment , VerticalAlignment , margins etc.


2.12.7 System.Windows.Controls.ContentControl 

nbsp; This is the base class for all controls that have a single piece of content

2.12.8 System.Windows.Controls.ItemsControl

This is the base class for all controls that show a collection of items, such as the ListBox and TreeView.

2.12.9 System.Windows.Controls.Panel



2.12.10 System.Windows.Shapes.Shape


2.12.11 System.Windows.Controls.Control

This class has controls like TextBox, Button, ListBox etc.

2.13  WPF TIERS:

Video cards differ significantly. When WPF assesses a video card, it considers a number of factors, including the amount of RAM on the video card.WPF recognizes three rendering tiers. They are as follows:

2.13.1      Rendering Tier 0

The video card will not provide any hardware acceleration. This corresponds to a DirectX version level of less than 7.0.

2.13.2   Rendering Tier 1

The video card can provide partial hardware acceleration. This corresponds to a DirectX version level greater than 7.0 but less than 9.0.

2.13.3  Rendering Tier 2

All features that can be hardware accelerated. This corresponds to a DirectX version level greater than or equal to 9.0.

2.14 WPF: A Higher-Level API:

If the only thing WPF offered was hardware acceleration through DirectX, it would be a compelling improvement, but not a revolutionary one.
 But WPF actually includes a basket of high-level services designed for application programmers.
A web-like layout model
 Flexible Highly dynamic content.


2.14.1 A rich drawing model 

 Rather than painting pixels, in WPF you deal with primitives, basic shapes, blocks of text,  and other graphical ingredients. You also have new features, such as true transparent  controls and native 3-D support.

 Note: The 3-D support in WPF is not as mature as Direct3D or OpenGL. If you are  planning to design an application that makes heavy use of three-dimensional such as  a real- time game.

2.14.2 A rich text model 

 WPF gives Windows applications the ability to display rich, styled text anywhere in a  user  interface. You can even combine text with lists.

2.14.3  Animation as a first-class programming concept 

nbsp;You could use a timer to force a form to repaint itself. But in WPF, animation is an  intrinsic part of the framework. You define animations with declarative tags, and WPF  puts them into action automatically.

2.14.4 Support for audio and video media 

Previous user interface toolkits, such as Windows Forms, were limited when dealing with  multimedia. But WPF includes support for playing any audio or video file supported by  Windows Media Player, and it allows you to play more than one media file at once. Even  more impressively, it gives you the tools to integrate video content into the rest of your user  interface, allowing you to place a video window on a spinning 3-D cube.

2.14.5  Styles and templates 

Styles allow you to standardize formatting and reuse it throughout your application.  Templates allow you to change the way any element is rendered, even a core control  such as  the button. It’s never been easier to build modern skinned interfaces.


2.14.6 Commands

Most users realize that it doesn’t matter whether they trigger the Open command  through a menu or a toolbar. The end result is the same. Now that abstraction is  available to your code,  you can define an application command in one place and link  it to  multiple controls.


2.14.7 Declarative user interface:

Although you can construct a WPF window with code, Visual Studio takes a different  approach. It serializes each window’s content to a set of XML tags in a XAML  document. The  advantage is that your user interface is completely separated from your code, and graphic  designers can use professional tools to edit your XAML files and refine your application’s  front end.


2.14.8 Page-based applications

Using WPF, you can build a browser-like application that lets you move through a  collection of pages, complete with forward and back navigation buttons. WPF  handles the messy details, such as the page history. You can even deploy your project  as a browser-based application that runs right inside Internet Explorer. 


2.15 Resolution Independence:

 Traditional Windows applications are bound by certain assumptions about resolution.
 Developers usually assume a standard monitor resolution (such as 1024 by 768 pixels), design their windows with that in mind
 The problem is that the user interface in traditional Windows applications isn’t scalable. As a result, if you use a high monitor resolution that crams pixels in more densely, your application windows become smaller and more difficult to read.
 Although you can resize graphical content that’s drawn with GDI/GDI+, User32 (which generates the visuals for common controls) doesn’t support true scaling.
 WPF doesn’t suffer from this problem because it renders all user interface elements itself, from simple shapes to common controls such as buttons.
 As a result, if you create a button that’s 1 inch wide on your computer monitor, it can remain 1 inch wide on a high-resolution monitor.
 WPF will simply render it in greater detail and with more pixels.
Note:
 Resolution independence also has advantages when printing the contents of a window.
 Most importantly, you need to realize that WPF bases its scaling on the system DPI setting, not the DPI of your physical display device.

2.16 Silverlight:

   “Subset of the WPF”
 Browser-based WPF applications are similarly limited, they can run only on Windows  computers,  although they support both the Internet Explorer and Firefox browsers.
  Silverlight applications are now supported on Firefox, Internet Explorer, Google Chrome  and Safari  browsers and operating systems (Microsoft Windows, Mac OS X, Linux through  moonlight, Windows Phone 7 and Symbian OS).

2.16.1 Silverlight 1.0


 This first release includes 2-D drawing features, animation, and media playback features that are similar to those in WPF.
 Silverlight 1.0 has no support for the .NET Framework or the C# and Visual Basic languages, instead, you must use JavaScript code.

2.16.2 Silverlight 2.0

 Silverlight 2.0 allows you to write code in a .NET language such as C# and Visual Basic.
 Neither version supports true three-dimensional drawing or rich document display.

2.16.3 Silverlight 3.0

 3D support
 Hardware acceleration
 The ultimate goal of Silverlight is to provide a powerful developer-oriented competitor for Adobe Flash.
 However, Flash has a key advantage. It’s used throughout the Web, and the Flash plug-in is installed just about everywhere.

2.16.4 Silverlight 4.0

 Support for Google's Chrome browser.
 Web cam and microphone support.
 Printing support.
 Improved mouse support including right button support and mouse wheel support.
 New notification support to display messages to end users.
 New and enhanced controls such as a RichTextBox and an enhanced DataGrid control.
 New support for implicit theming of controls.
 New hosted browser support for rendering HTML inside Silverlight.
 WCF data layer enhancements.
 Localization enhancements with bi-directional text.
 Support for Managed Extensibility Framework.
 Enhanced data binding support.
 Enhanced animation effects.
 Clipboard and drag and drop support.
 Deep Zoom performance enhancements.
 WCF Rich Internet application (RIA) Services.
 Content protection for H.264 and support for playing offline DRM protected media.
 Additionally, the following features are provided to out-of-browser (locally installed) Silverlight applications that have been explicitly granted "trusted" status:
 Full keyboard access while running in full screen mode.
 Programmatic access to a user's local document folder.
 Support for local Component Object Model (COM) objects

2.16.5 Silverlight 5.0

 Supports GPU accelerated video decoding
 Built in 3D graphics support (not to be confused with stereoscopic 3D)
 Variable speed playback of media content with automatic audio pitch correction
 Improved power awareness
 Built in Remote-control support
 Supports faster application startup
 Provides 64-bit browser support
 Automated UI testing support for applications with Visual Studio 2010
 Delivers improved text clarity
 Developers can now debug data-binding expressions, set breakpoints on bindings.

2.17 The Architecture of WPF:

 WPF uses a multilayered architecture. At the top, your application interacts with a high-level set of services that are completely written in managed C# code.
 The actual work of translating .NET objects into Direct3D textures and triangles happens behind the scenes, using a lowerlevel unmanaged component called milcore.dll.This class helps us to create basic shapes such as Rectangle, Polygon, Ellipse, Line, and Path.This is the base class for all layout containers       UIElement handled three important aspects layout, input and events.When an object edge falls in the middle of a pixel device, the DPI-independent graphics system can create rendering artifacts, such as blurry or semi-transparent edges. Previous versions of WPF included pixel snapping to help handle this case. Silverlight 2 introduced layout rounding, which is another way to move elements so that edges fall on whole pixel boundaries. WPF now supports layout rounding with the UseLayoutRounding attached property on FrameworkElement.   Several changes have been made related to graphics and animations.

2.17.1 PresentationFramework.dll

 Holds the top-level WPF types, including those that represent windows, panels, and other  types of controls.
 It also implements higher-level programming abstractions such as styles.
 Most of the classes you’ll use directly come from this assembly.

2.17.2 PresentationCore.dll

 Holds base types, such as UIElement and Visual, from which all shapes and controls derive.

2.17.3  WindowsBase.dll
 Holds even more basic ingredients that have the potential to be reused outside of WPF, such as DispatcherObject and DependencyObject, which introduces the plumbing for dependency  properties.

2.17.4 Milcore.dll

 Milcore.dll is implemented in unmanaged code because it needs tight integration with  Direct3D and because it’s extremely performance-sensitive.

 Is the core of the WPF rendering system and the foundation of the Media Integration Layer (MIL).
 Its composition engine translates visual elements into the triangle and textures that Direct3D expects.
 Milcore.dll is considered a part of WPF, it’s also an essential system component for Windows Vista.
 Desktop Window Manager (DWM) in Windows Vista uses milcore.dll to render the desktop.

Note:

 Milcore.dll is sometimes referred to as the engine for “managed graphics.” Much as the common language runtime (CLR) manages the lifetime of a .NET application, milcore.dll manages the display state.
 Just as the CLR saves you from worrying about releasing objects and reclaiming memory, milcore.dll save you from thinking about invalidating and repainting a window.
 Milcore.dll paints the appropriate portions of the window as it is dragged around, covered and uncovered, minimized and restored, and so on.

2.17.5 User32

 It’s still involved in WPF, but it plays no part in rendering common controls.

3 References

1. http://msdn.microsoft.com/en-us/library/bb613588.aspx
2. http://en.wikipedia.org/wiki/Microsoft_Silverlight
3. http://weblogs.asp.net/scottgu/archive/2009/10/26/wpf-4-vs-2010-and-net-4-0-series.aspx

3.1         Book References

1. Matthew MacDonald, Pro WPF in C Sharp 2008 2ndEdition, Feb2008,  APRESS, ISBN: 1-59059-955-1.

4 comments:

  1. Hi..
    Very good article about wpf understanding.
    Thanks for sharing us.

    ReplyDelete
  2. Thanks maifs I appreciate your work what you did.

    ReplyDelete
  3. Thnaks for sharing...keep it up :) and also try it ==>> Microsoft Toolkit 2.7.6

    ReplyDelete
  4. Great set of tips from the master himself. Excellent ideas. Anyone wishing to take their blogging forward must read these tips. Thank you .microsoft toolkit 2.7.6 for windows

    ReplyDelete