
1. WPF Introduction
Introduction to Windows Presentation Foundation (WPF)
Windows Presentation Foundation (WPF) is a UI framework for building Windows desktop applications. It provides a unified programming model for building rich, modern desktop applications with clean UI design.
WPF Components
WPF is primarily composed of two parts:
- The C# language for the backend logic.
- XAML (Extensible Application Markup Language) for designing the user interface.
Advantages of WPF
Unlike traditional Windows Forms, WPF provides a binding system and uses your computer's graphics card for rendering, resulting in a more responsive and visually pleasing user interface.
- Binding System: WPF offers a robust data binding system, allowing for efficient communication between different forms (which was not available in Windows Forms). This makes it easier to reflect changes in your data across your UI and vice versa.
- Graphics Rendering: While Windows Forms relies on the CPU for rendering, WPF utilizes the graphics card. This results in better performance and a more visually appealing UI.
XAML in WPF
XAML stands for Extensible Application Markup Language. Used in conjunction with C#, it is primarily responsible for creating and managing UI elements in WPF.
The advantage of using XAML is that it is processed by the graphics card, providing an improved performance compared to Windows Forms that rely solely on the CPU for rendering.
Example:
<Window x:Class="WpfApp1.MainWindow"
xmlns="<http://schemas.microsoft.com/winfx/2006/xaml/presentation>"
xmlns:x="<http://schemas.microsoft.com/winfx/2006/xaml>"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Button Content="Button" HorizontalAlignment="Left" Margin="197,123,0,0" VerticalAlignment="Top" Width="75"/>
</Grid>
</Window>
Key Concepts Covered
Throughout the study of WPF, we have covered various key concepts:
- Padding and Margin: These are properties that control layout behavior in WPF. Padding adds space within an element, while Margin adds space around an element.
- Button: It is a basic UI control that the user can click to perform an action.
- Grid: It is a flexible layout panel that arranges its child elements in rows and columns.
- Content: It is a property that gets or sets the content of a ContentControl.
- StackPanel: It is a simple layout panel, which arranges its child elements into a single line that can be oriented horizontally or vertically.
Reference
The content in this document is based on the original notes provided in Azerbaijani. For further details, you can refer to the original document using the following link:
Original Note - Azerbaijani Version