
12. Practise 2
WPF (Windows Presentation Foundation) Practice 2
Introduction to WPF
Windows Presentation Foundation (WPF) is a UI framework that creates desktop client applications. The WPF development platform supports a broad set of application development features, including an application model, resources, controls, graphics, layout, data binding, and documents.
Key Points:
- WPF uses the .NET Framework, which means you can create apps that incorporate a wide range of extra functionality.
- WPF is a part of the .NET Framework, so if you have previously built applications with the .NET Framework using ASP.NET or Windows Forms, the fundamental .NET concepts apply to WPF as well.
WPF Architecture
Understanding the WPF architecture is essential for using its rich set of features effectively. The architecture is designed in layers, each one building on top of the one below it.
- PresentationFramework Layer: This layer is responsible for user-friendly features like layout, styling, and controls.
- PresentationCore Layer: It is essentially a wrapper around the milcore and provides services which are not available in milcore.
- MilCore (Media Integration Layer): This layer is responsible for rendering the WPF applications.
Working with WPF
Creating a WPF Application in Visual Studio
Here is a simple example of creating a WPF application in Visual Studio:
// Create a new WPF Application project
// File -> New -> Project -> WPF App (.NET Framework)
After creating the project, you will see a MainWindow.xaml file:
<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>
</Grid>
</Window>
Working with Controls
Controls are the building blocks of a WPF application. For example, here is how you can add a Button control to your application:
<Button Content="Click me" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="75"/>
Conclusion
WPF is a powerful framework for building Windows desktop applications. It provides a unified approach to UI design by combining the best of both Windows Forms and HTML. This was a brief introduction to WPF and in subsequent lessons, we will delve deeper into its features and functionalities.
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