New and enhanced features in Windows Presentation Foundation (WPF) version 4.0 are:
• New Controls
• Visual State Manager
• Touch and Manipulation
• Graphics and Animations
• WPF and Silver light Designer
Three new controls have been added to WPF. These controls are almost 100 percent compatible with the Silver light versions. This enables developers to reuse code and quickly create client and Web versions.
• Data Grid
• Date Picker
Visual State Manager
• WPF provides better support for changing visual states in a Control Template. The Visual State Manager 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.
Touch and Manipulation
• Elements in WPF now accept touch input. The UIElement, and UIElement3D, and Content Element classes expose events that occur when a user touches an element on a touch-enabled screen. In addition to the touch events, the UIElement supports manipulation. A manipulation is interpreted to scale, rotate, or translate the UIElement. For example, a photo viewing application might allow users to move, zoom, resize, and rotate a photo by touching the computer screen over the photo.
Graphics and Animations
Several changes have been made related to graphics and animations.
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. Silver light 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 Framework Element.
By using the new Bitmap Cache 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.
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.
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
Several changes have been made related to text.
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 Clear Type 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.
Selection and Caret Customization
You can now specify the brush that paints the selection and caret for input and reading controls, such as TextBoxRichTextBox, and FlowDocumentReader. There are two new properties on Textbox Base:
- SelectionBrush: allows you to create a brush for highlighting selected text.
- CaretBrush: allows you to change the brush that paints the cursor.
Various changes and enhancements have been made related to binding.
Bind to commands on Input Binding.
You can bind the Command property of an Input Binding class to an instance that is defined in code. The following properties are dependency properties, so that they can be targets of bindings:
Bind to Dynamic Objects
WPF supports data binding to objects that implement IDynamicMetaObjectProvider. For example, if you create a dynamic object that inherits from Dynamic Object in code, you can use markup extension to bind to the object in XAML. For more information, see the Binding Sources Overview.
Bindable Text Run
Run.Text is now a dependency property. The main advantage is that it now supports one-way bindings. It also supports other features of dependency properties, such as styling and templating.
WPF and Silver light Designer
In Visual Studio 2010, various designer improvements have been made to help create WPF or Silverlight applications.
Improved Support for Silver light
In Visual Studio 2008, you could install the Silver light Tools to create Silver light applications in Visual Studio. However, the designer support for Silver light projects was limited. In Visual Studio 2010, the designer support for Silver light and WPF projects are now the same. For example, in Silver light projects you can now select and position items with the mouse on the design surface.
Support for Multiple Platform Versions
In Visual Studio 2008, control design times were able to target only the latest WPF platform version. In Visual Studio 2010, this support is extended across multiple platforms, including design-time support for WPF 3.5, WPF 4, Silver light 3, Silver light 4, and future platform releases. As the same extensibility API exists for all these platforms, control design-time authors can easily write one experience and share it across the control runtimes for each platform.
Visual Data binding
The new data binding builder enables visual construction and editing of bindings without typing XAML.
Layout improvements include a more intuitive Grid designer and better support for automatically sizing user controls.
Improved Property Editing
The Properties window now enables visually creating and editing Brush resources.