Windows Presentation Foundation
lastmod 2024-11-08created 2024-07-3035 edits
Windows Presentation Foundation is a graphics subsystem made by Microsoft for displaying user interfaces in Windows-based applications. Formerly known by the codename Avalon, it was first released as part of .NET Framework 3.0, and it uses DirectX instead of the existing Graphics Device Interface. WPF provides a consistent programming model for application development and separates the user interface from business logic. It is similar to XML-based object models such as XUL and SVG.
WPF adopts XAML, an XML-based language, to define and link various interface elements. WPF applications can run standalone on the desktop or be served as objects embedded in a website. WPF aims to unify many common user interface elements such as 2D/3D rendering, fixed and adaptive documents, typography, vector graphics, real-time animation, and pre-rendered media. These elements can be linked and handled based on various events, user interaction, and data binding.
The WPF runtime library is included by default in all versions of Microsoft Windows starting with Windows Vista and Windows Server 2008. Users of Windows XP SP2/SP3 and Windows Server 2003 can optionally install the required libraries.
Microsoft Silverlight provides embedded web controls similar to Adobe Flash, most of which correspond to a subset of WPF. Real-time 3D rendering has been available since Silverlight 5.
Categories
System.Windows.Data
- Binding - Provides high-level access to the definition of a binding, which connects the properties of binding target objects (typically WPF elements) and any data source (for example, a database, an XML file, or any object that contains data).
System.Windows.Controls
Provides classes for creating elements, known as controls, that enable a user to interact with an application.
- DataGrid - Represents a control that displays data in a customizable grid.
- Grid - Defines a flexible grid area that consists of columns and rows.
- Image - Represents a control that displays an image.
- RadioButton - Represents a button that can be selected, but not cleared, by a user.
- ScrollViewer - Represents a scrollable area that can contain other visible elements.
- TextBlock - Provides a lightweight control for displaying small amounts of flow content.
- UserControl - Provides a simple way to create a control.
Windows Runtime APIs
Windows.UI.Xaml
- Windows.UI.Xaml Namespace - Windows UWP applications | Microsoft Learn
- Windows.UI.Xaml.Style - Contains property setters that can be shared between instances of a type. A Style is usually declared in a resources collection so that it can be shared and used for applying control templates and other styles.
Transform
Transform is a feature that changes only the appearance of a control while leaving its actual properties as they are.
It makes moving, resizing, rotating, and so on of controls such as Button very easy. Even if you change the size using Transform, the actual size of the button does not change.
- TranslateTransform - Translates (moves) an object in the 2-D x-y coordinate system.
- RotateTransform - Rotates an object clockwise about a specified point in a 2-D x-y coordinate system.
- ScaleTransform - Scales an object in the 2-D x-y coordinate system.
- SkewTransform - Represents a 2-D skew applied to an object.
- MatrixTransform - Creates an arbitrary affine matrix transformation that is used to manipulate objects or coordinate systems in a 2-D plane.
RenderTransform vs LayoutTransform
The difference between RenderTransform and LayoutTransform is the point at which the Transform is applied.
- LayoutTransform - Measure, Arrange
- RenderTransform - Render
Layouts
- [Recommended] ( C#- WPF ) Basic theory
| Panel | Features | Overlap |
| Canvas | The most basic panel; child elements can be placed at any desired position. | O |
| StackPanel | Arranges child elements in a single line, horizontally or vertically. | X |
| WrapPanel | Similar to StackPanel, but places child elements in order from left to right, and moves them to the next line when they exceed the available size. | X |
| DockPanel | Places child elements in each specified direction. | X |
| Grid | The most powerful panel; places child elements in a table layout. | O |
Troubleshooting
When focus moves to another component after a KeyDown event and consecutive key-downs stop working
Keep the focus, then signal that the event has been consumed.
private void Page_KeyDown(object sender, KeyEventArgs e)
{
YouComponent.Focus(); // 당신의 컴포넌트에 포커스를 활성화. (필요에 따라 사용)
e.Handled = true; // 이벤트를 처리했음을 알린다. 이후 다른 이벤트 핸들러 호출을 중단한다.
}
See also
- MS
- .NET
- Universal Windows Platform (UWP)
- Windows Presentation Foundation (WPF)
- Avalonia UI - Take your WPF apps to macOS and Linux
- Blend - Component designer
- Visual Studio
- XAML
Favorite site
Basics
- Create a Hello World app with WPF in C# - Visual Studio (Windows) | Microsoft Learn
- [Recommended] ( C#- WPF ) Basic theory
- WPF basics (XAML) - Dreaming of fun development..
- (Learning WPF MVVM in a week) Ⅰ. First .. : Naver Blog