Windows Presentation Foundation

from Wikipedia, the free encyclopedia
Windows Presentation Foundation
Basic data

developer Microsoft
Current  version 4.7.2
(April 30, 2018)
operating system from Windows XP Service Pack 2
category GUI framework
License Proprietary software
German speaking Yes
Microsoft's official WPF website

Windows Presentation Foundation ( WPF for short ), also known under the code name Avalon , is a graphics framework and window system of the .NET Framework from Microsoft . It has been supplied with Windows since Windows Vista and can be installed on Windows XP (up to version 4.0) and Windows Server 2003 . WPF has been available for .NET Core since version 3.0 under Windows.

WPF is a class library introduced in 2006 that is used to design graphical user interfaces and to integrate multimedia components and animations. It combines DirectX, Windows Forms, Adobe Flash, HTML and CSS.

WPF provides a comprehensive model for the programmer. The presentation and the business logic are separated, this is mainly supported by the XAML markup language (based on XML). XAML declaratively describes user interface hierarchies as XML code. WPF applications can be both desktop and web applications and use hardware acceleration when possible . The framework tries to unite the different areas that are important for the presentation (user interface, drawing and graphics, audio and video, documents, typography).

There is also Microsoft Silverlight (formerly WPF / E ), a platform that was developed for the web. Silverlight is not based on the .NET framework, but uses a reduced version of it. Silverlight can be developed with XAML.

Sample application using WPF

construction

WPF is part of the .NET Framework 3.0 and higher, actually builds on the Framework 2.0. A large object-oriented class library is available with the .NET framework as the basis . A wide variety of programming languages ​​can be used to generate CIL intermediate code, e.g. B. C # or VB.NET .

Performance characteristics

WPF makes a number of performance features available to applications based on this.

Properties and Events

In contrast to normal applications, WPF uses its own kind of properties, called dependency properties . These are necessary because some properties in WPF can depend on others, for example the position of an image during an animation. These properties also provide support for data binding and validation.

The events are different. Routed events are used in WPF . This is because elements can contain other elements. If a child element triggers an event, this is forwarded to the parent element in order not to monitor each individual child element. This is called a bubble event . Conversely, it can make sense to receive an event as a parent element before the child element ( tunnel event ).

Dependency properties and routed events can be attached , i.e. an element can receive a property or an event from another element depending on the context. This is the case when a button is in a grid: properties for positioning (column and row) are made available.

A button with an effect that contains other controls (menu, slider, checkbox) and a rectangle.

graphic

All graphic elements (e.g. windows) are rendered with Direct3D . As a result, some tasks are accelerated by the GPU of the graphics card instead of the CPU . In addition, 3D graphics can be displayed in 2D applications. Vector graphics are supported. Bitmap effects are offered up to version 3.5 of the WPF, but these are rendered without hardware acceleration , which is why they are declared obsolete in the current version 4.0. Instead of the bitmap effects, "normal" effects such as the DropShadowEffect should now be used, which consistently use the hardware acceleration of the graphics card.

Interoperability

Windows Forms controls can be used in WPF applications and vice versa WPF elements can be used in Windows Forms.

WPF also supports Win32 : WPF can be used in Win32 code via hosting, and Win32 code can continue to be used in WPF applications.

Media and documents

WPF provides 2D primitives with predefined transformations , textures, etc. The 3D functionalities are a sub-part of Direct3D . However, these functionalities are available for documents and user interfaces. Individual animations are also possible. These can also run time-controlled. Most graphic formats and videos in WMV or MPEG format are supported, whereby Windows Media Player version 9 or higher is required. Documents, especially XPS documents, are also supported with predefined controls.

Text and typography

WPF supports many OpenType features , such as ligatures , small caps, and ruby . OpenType and TrueType fonts are supported. Since it is based on .NET, WPF always treats text as Unicode regardless of the character encoding .

User interface

WPF already contains some predefined controls, such as menus , lists. In addition, the appearance is separated from the control logic. The appearance of a control can be changed independently with styles (adapting properties) and templates (defining how the control is structured).

Controls can contain any other control or content.

Browser applications

WPF applications can run in a web browser . These XAML browser applications ( XBAP ) run in a restricted sandbox environment to protect against malicious applications . Using the usual Internet restrictions, an XBAP does not have the functionality of the .NET framework. This range of functions can still be achieved using certificates.

Since the release of the .NET Framework 3.5, XBAPs have been running with a plug-in in Mozilla Firefox .

XAML

The Extensible Application Markup Language ( XAML ), which is based on XML , declaratively describes application interfaces for WPF. This tries to separate the appearance from the logic.

Silverlight

Silverlight is a platform-independent browser extension that provides a WPF-like framework for the web. This includes video, vector graphics, animations. Silverlight is currently available for Mozilla Firefox, Internet Explorer , Opera and Safari on Windows and Mac OS X. In Google Chrome and Microsoft Edge , however, Silverlight is not supported and is also not planned. The Mono project created an implementation for GNU / Linux called Moonlight . However, further development was discontinued.

Design applications

Microsoft Visual Studio 2019, 2017, 2015, 2013, 2012, 2010, 2008 (2005 with extension) and SharpDevelop can be used to design applications . WPF is supported there by a WYSIWYG designer and a suitable XAML editor.

There is also a new series of creative development tools called Microsoft Expression . Expression Blend edits user interfaces (for Silverlight) and works together with Visual Studio.

See also

literature

  • Adam Nathan: Windows Presentation Foundation Unleashed. Sams, 2007, ISBN 978-0-672-32891-6 .
  • Charles Petzold: Application = Code + Markup. Microsoft Press, 2006, ISBN 978-3-86645-407-1 .
  • Thomas Claudius Huber: Windows Presentation Foundation. Galileo Computing, June 2008, ISBN 978-3-8362-1108-6 .
  • Matthew MacDonald Pro WPF in C # 2008. Windows Presentation Foundation with .Net 3.5. Apress, February 2008, ISBN 978-1-59059-955-6 .
  • Dirk Frischalowski: Windows Presentation Foundation. Developing graphical interfaces with .NET 3.0. Addison-Wesley, March 2007, ISBN 978-3-8273-2522-8 .
  • Thomas Theis: Entry into WPF 4.5. Basics and practice. 2nd, updated and exp. Edition, Galileo Press, Bonn 2013, ISBN 978-3-8362-1967-9 .

Individual evidence

  1. Announcing the .NET Framework 4.7.2 , .NET Blog, May 2, 2017
  2. heise online: Microsoft Connect () 2018: First preview version of .NET Core 3.0. Retrieved December 5, 2018 .
  3. ^ Thomas Theis, Introduction to WPF 4.5. Basics and practice. 2nd edition, Galileo Press, Bonn 2013, p. 15.
  4. MSDN
  5. http://marlongrech.wordpress.com/2008/05/15/effects-in-net-sp1-for-wpf/
  6. Effects
  7. DropShadowEffect
  8. FirefoxWPFAndXBAP

Web links