⬆️ ⬇️

WPF 4

Innovations in WPF 4 image



WPF (Windows Presentation Foundation) is one of the components of the .NET Framework kernel that allows developers to create rich, diverse Windows applications. WPF 4 contains important improvements in productivity, performance, capabilities — in particular in the following areas: controls, XAML, text, graphics, integration in Windows 7 (multitouch, integration into the taskbar, etc.), basic operating principles, deployment . This is only the first article in the series that describes the innovations.



I will write a separate article that describes the important changes that are coming up in WPF and Silverlight designers in VS 2010.



Controls



Controls for building rich applications image

')

WPF 4 adds a variety of controls to create business applications even faster and easier. A new, rich set of controls includes the LOB-required controls, such as a DataGrid, DatePicker and Calendar. These new controls are 99% behavioral and API compatible with their Silverlight counterparts, allowing the developer to create compatible web and client applications, streamlining the workflow through the reuse of Silverlight and WPF code.



Cunning tricks



We also release a set of eight controls called WPF Bag O 'Tricks. The set includes: AnimatingTilePanel, ColorPicker, InfoTextBox, ListPager, NumericUpDown, Reveal, TransitionsPresenter, TreeMapPanel.



Windows 7 and Office Ribbon Control



The new WPF Ribbon control will be available almost immediately after the release of WPF 4. It supports all the standard features that the end user is familiar with: bookmarks and groups, dynamic resizing, quick access toolbar, application menu, context-sensitive bookmarks, hot keys and more.



image



The WPF version of Ribbon will have full extensibility to match the changes in guidance in future releases. Limited CTP version available today.



Graphics



Cached Build Applications

image

Huge performance gains are possible with the new WPF4 Cached Composition feature, which allows applications to cache arbitrary content, including live and fully interactive controls, vector geometry, bitmaps stored in video memory, and so on. Having placed the elements in the cache once, it can be arbitrarily transformed, animated, controlled, Effects can be applied to them, without need to redraw the cached elements.



All this leads to saving the CPU and GPU from redrawing the contents and allows the GPU to redraw directly from the cache. The cache understands the "dirty" areas, so the flashing cursor in the cached text block, for example, will have to redraw only the cursor between frames. There is even a new brush that uses a “smart” cache, in fact, this is a VisualBrush with improved performance.



Third pixel shader support



WPF is based on the support of the popular ShaderEffect, first introduced in WPF 3.5 SP1, which allows you to create effects using pixel shaders 3rd version. PS 3.0 is more complex than PS 2.0, which makes it possible to create compelling effects on supported hardware.



LayoutRounding



WPF 4 adopted the UseLayoutRounding property introduced in Silverlight 2. The layout engine often calculates the sub-pixel position coordinates. This leads to artifacts when drawing, when the element is located at the junction of sub-pixel boundaries and smoothed over several physical pixels.



UseLayoutRounding will force the layout engine to position elements along all pixel boundaries, therefore, removing most of the drawing artifacts caused by this problem, which allows you to create a clean and clear default UI.



Functions to facilitate animation

image

Discrete, linear and spline animations are already supported by previous versions of WPF. WPF 4 introduces the new Easing Functions concept, which allows developers to create different animations. For example, springy movements or add anticipation to the animation . Easing Functions define how to animate from start to finish. Built-in simplification features provide a range of modes in animation: circular, exponential, elastic, and springy. Simplification features are designed to be easily extensible, allowing developers to create their own. Thanks to this innovation, designers can effortlessly create smooth and organic animation.



Cleartypehint



The new added property CleartypeHint allows application developers to enable high-quality drawing of Cleartype text when in many situations it has been previously disabled. Such situations include text in layered windows, text in VisualBrush, DrawingBrush, BitmapCacheBrush, and everywhere where the intermediate rendering view will be the previous result in black and white text.



Text stack



New stack for drawing text



The WPF text rendering stack has been completely replaced, a change that leads to significant improvements in the clarity of text rendering, the ability to change settings and support for international languages. This new text stack supports an optimized character layer to display text with comparable text sharpness in Win32 / GDI:



image



The new stack also supports explicitly selectable text rendering modes: aliased, grayscale, ClearType.



image



New text stack allows you to optimize the text binding for animation and static. In addition, the new text stack supports fonts with embedded image maps, which allows many East Asian fonts to be drawn with the clarity that Win32 users are used to.



BindableRun



With the release of WPF, Run.Text was a simple CLR property. This means that Run.Text lacks all the advantages of the property dependency system in WPF, the most significant of which is binding. In WPF 4, we converted Run.Text into a dependent property that allows developers to use the data-bound Run for the first time. More information about this here .



Own dictionaries



WPF includes a spell checker, which up to version 4 used the dictionaries provided by the OS. This was a big problem for applications that use specific terminology, these applications were annoying with constant misspell notifications. WPF 4 introduces an API that allows applications to add words to dictionaries used by WPF for spell checking. More on this here .



Selection brush and carriage



In a rush to allow developers to customize the rich look of WPF applications, now you can change the brush to highlight text and carriage through two simple properties - SelectionBrush and CaretBrush:



image



Windows 7



Multitouch support

image

With the introduction of multi-touch input and handling manipulation, WPF 4 provides a great way to add flavor to your client application in Windows 7. There are new manipulation and inertia events:



Integration with Windows 7 interface



WPF 4 provides new and key functionality in Windows 7 for WPF developers. The new taskbar is cluttered and can transfer more information. Aero-pictograms support user commands. The Jump List provides access to contextual launch of tasks and files for an application.



WPF 4 integrates with the functionality of the Windows 7 Jump List, including:image Integration with the Windows 7 taskbar, including:

In Windows 7, the taskbar has been completely redesigned to reduce clutter and improve user assistance in performing tasks with a few clicks. WPF 4 provides integration with the Windows 7 taskbar in XAML, allowing applications to display useful information to the user via icons in the taskbar, using overlay icons, progress indicator, icon bar, icon description text, and window thumbnails in the taskbar.

There is also a new class TaskbarItemInfo, which is expanded as a dependency property. It contains all the new features of the taskbar in Windows 7.



Icon Overlay (Icon Overlays) image



The overlay icon allows the application to display certain notifications and status to the user through its own button in the taskbar, displaying a small overlay that appears in the lower right corner of the button.



Progress indicator



The button in the task panel can be used to display simple information about the progress, eliminating the need to open a window to view the status. The progress indicator can be used to track the process of copying files, downloading, installing, writing data to a disk or other operation that takes a certain period of time.



Thumbnail Toolbars

image

Thumbnail panels provide access to key commands for the application without the need of the user to activate or maximize the application window. This functionality allows application developers to embed application controls directly into a thumbnail preview window. The application can enable, disable, or hide buttons from the thumbnail panel, depending on the current state.



WPF Basics



New XAML / BAML parser engine



In WPF 4, the implementation of XamlReader.Load (), BAML-loading, the Control & DataTemplate functionality with a new engine based on the new System.Xaml.dll has been replaced. As part of the effort, we fixed a lot of bugs and added many new functional improvements. XamlReader.Load () users can take advantage of several new language features in XAML2009, such as generic type support. MarkupExtensions and TypeConverters can now access many services through the creation of an object graph, allowing you to perform more scripts, like access to a Root object. It will be even easier to create tools for analyzing and manipulating XAML with the new low-level APIs provided by System.Xaml.dll.



Data Binding Support for DLR



Unlike CLR classes, members of dynamic objects are declared at runtime. DynamicObject is a new abstract class in the .NET Framework 4 that allows developers to easily implement IDynamicMetaObjectProvider. With DLR support in C # with the new 'dynamic' keyword, we expect some library implementations to switch to using DynamicObject and IDynamicMetaObjectProvider as the standard way to extend properties declared in runtime and objects. Data binding support for IDF in WPF 4’s IDynamicMetaObjectProvider allows you to use normal properties to access dynamic properties.



This functionality extends the data binding engine in WPF to indicate to existing properties and indexers the syntax of referencing data bound to support access to dynamic members of the proposed IDynamicMetaObjectProvider.



Visual State Manager (VSM)



Other new features support the WPF-Silverlight continuum in the VisualStateManager, which introduces a new easy way to apply visual states of controls. The mechanism allows you to customize the appearance and behavior of the control, providing a means of specifying control logic to its corresponding beginning and end of visual states.



image



VSM is very flexible in generating transition animations to the appropriate states, hence the control author spends less time writing code and more time looking at it. This means that VSM can give the control author the ability to easily change the behavior and appearance of the controls, as well as change the visual response of the control to a user action. All of this is fully supported in Expression Blend.



HTML-XBAP Script Interop



WPF 4 provides the means for direct communication between XBAP and scripts in a hosted HTML page (where XBAP is loaded into an HTML frame or IFRAME element). XBAP can gain deep access to the HTML DOM, including ActiveX controls embedded in the HTML containing page, and also handle DOM events.



WPF opens the main script object in a hosted frame. This is a dynamic object that represents a frame window object, as well as any functions or global variables in a script on an HTML page. From there, an application can call script functions directly or access an HTML DOM. This functionality is available in partial-trust XBAP and in all supported versions of Internet Explorer and Firefox.



UIAutomation Virtualization



WPF introduced virtualized controls in previous versions. However, there was no standardized way for a client to automate interactions with a virtualized control. Two new control templates have been added to WPF 4 - ItemsContainerPattern and VirtualizedItemPattern, to support access and interaction with virtualized items. ItemsContainerPattern is used to access virtualized controls and search for a virtualized item, and VirtualizedItemPattern to implement virtualized items.



SynchronizedInput Template



This is another UIA control design pattern added in WPF 4. This pattern is used by automation clients to track the direction of specified input events to the correct WPF element by the framework. This template has three automation events: InputReachedTargetEvent, InputReachedOtherElementEvent, and InputDiscardedEvent, to indicate whether the input has been processed.



Deployment



.NET Framework 4 Client Profile



To optimize the deployment size and time of the .NET 4 framework, there is a compact version of .NET, which is a subset of the complete .NET 4 framework, called the .NET Framework 4 CLient Profile . The current size of the .NET Framework 4 Client Profile distribution is approximately 30 MB. The full version of the Microsoft .NET Framework 4 is a slightly enhanced version of the Client Profile.



The Client Profile contains functionality for most common desktop applications (including Windows Forms and WPF applications), so most developers are expected to focus on this version, and not on the full version. For this reason, most Visual Studio 2010 Beta 2 client project templates are focused on the .NET Framework 4 Beta 2 Client Profile by default.



Unlike the .NET Framework 3.5 SP1 Client Profile, version 4 supports all operating systems and platforms, including those supported by the full version: Windows Vista, Windows XP, Windows Servers 2003 and 2008, Windows 7, both x86 and x64.



You can view and change the version of the framework you are targeting development by opening the project properties and then selecting the “Application” tab. Next, select the full version or Client Profile in the “Target framework” dropdown list. In the "Publish" properties of the project, you can also select the required version for ClickOnce deployment. In Beta2, VS2010 automatically selects the correct profile, depending on your primary focus of the project:



image



You will see the same dialog box when you create the “Setup and Deployment” project (“Add New Project” / “Other Project Types”). NET4 Client Profile is highlighted in the default list.



Improvements in .NET4 Client Profile relative to .NET 3.5 SP1 Client Profile



Despite the fact that the concept of the Client Profile is not new and was introduced in the .NET Framework 3.5 SP1, the 4th version of the Client Profile contains several important improvements.



.NET Framework 4 Client Profile (New).NET Framework 3.5 SP1 Client Profile
Supported OSSupported on all platforms and operating systems supported by the .NET Framework (excluding IA64 and Server Core role in W2K8)Supported only on Windows XP 32-bit, on which no .NET Framework version is installed anymore.
SpreadStandard or Web DownloadDownload only from web
Add / remove program componentsThe full version of the framework consists of two parts - Client Profile and “Extended”. This gives us 2 points in the "Add / Remove Programs."



If you installed the full version of the framework, you can switch to the Client Profile by removing “Extended”
Only one item in Add / Remove Programs
Visual studioImproved support for orientation to the client profile in Visual Studio 2010.



By default, most client projects in Visual Studio Beta2 are focused on the .NET4 Client Profile.
The only tick in Visual Studio SP1 in the “Application” project settings tab, for .NET 3.5 projects. Support Client Profile out of the box in VS 2008 is not available.
OpportunitiesIncludes new features of .NET 4 (Managed Extensibility Framework (MEF), C # 4 Dynamic Keyword, etc.), as presented earlier in the full version of .NET 3.5 (Speech, WPF Spell Check, etc.)Subset of features in the full version of .NET 3.5 SP1




Installing .NET 4 framework does not require previous versions installed on the system. Therefore, installing the .NET 4.0 Client Profile will be several times faster than .NET 3.5 SP1 Client Profile.



Full trust deployment of XBAP applications



Beginning with WPF 4, a ClickOnce privilege elevation request is also enabled for XAML Browser Applications (XBAPs) for intranets and trust zones, making re-deployment even easier for full-trust XBAP applications. For those applications that require elevated security rights than the minimum code access rights (CAS), the user must select “Run” when requesting elevation of ClickOnce privileges to run XBAP with the required rights.



Conclusion



As can be seen from the above, there appeared a lot of innovations in WPF 4.0. Below are a few links and resources where you can explore new features in more detail:

Source: https://habr.com/ru/post/73633/



All Articles