11. Practise 1

Practice 1: Introduction to Windows Presentation Foundation (WPF)

Overview of WPF

Windows Presentation Foundation (WPF) is a graphical subsystem by Microsoft for rendering user interfaces in Windows-based applications. It was initially released as part of .NET Framework 3.0. WPF, unlike WinForms, is based on DirectX, not GDI. It provides a consistent programming model for building applications and provides a clear separation between the user interface and the business logic.

Key Points:

Creating a WPF Application

Creating a WPF Application involves the following steps:

  1. Open Visual Studio and select Create a new project.
  1. In the new project dialog, choose WPF App (.NET Framework).
  1. Name your project and select a location to save it.
  1. Click on Create. Visual Studio creates a new WPF application project.

WPF Application Structure

A basic WPF application consists of the following:

Basic XAML Syntax

XAML is a declarative markup language. You use tags to define elements in the UI. Here is a simple example of a button defined in XAML:

<Button Content="Click me" Width="200" Height="30" />

Data Binding in WPF

Data binding is a mechanism in WPF applications that provides a simple and easy way for Windows Runtime apps to display and interact with data. It links between the data in your ViewModel and the UI.

Example:

<TextBox Text="{Binding Path=Name}" />

In this example, the Text property of TextBox is bound to the Name property. Any changes in the Name property will reflect on the TextBox.

Conclusion

WPF is a powerful framework for building Windows desktop applications. It provides a robust and flexible model for building rich user interfaces, with great support for data binding, styling, and control customization. Remember, these are just the basics of WPF and there is much more to learn and explore.

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