logo
Учебник_ПОА

Создание пользовательского интерфейса для приложения wpf

Создание пользовательского интерфейса для приложения Windows Presentation Foundation (WPF) аналогично такому же процессу для приложения Windows Forms. Он заключается в перетаскивании элементов управления из панели элементов на поверхность разработки. Интегрированная среда разработки имеет отличия в приложениях WPF. Кроме окна Свойства и панели элементов, IDE WPF располагает редактором XAML. XAML — это язык XAML (расширяемый язык исправления31 для приложений), используемый для создания пользовательского интерфейса. На следующем рисунке изображено расположение редактора XAML.

Редактор XAML

Just as you can create a control by writing code manually in Windows Forms development, you can use XAML markup to create controls. In most cases, you would not write XAML to create controls; it is much easier to drag the controls from the Toolbox and let Visual C# Express Edition generate the XAML for you. You can then modify the XAML markup to change attributes of the control, such as its Height or Text. For example, the following XAML markup resembles the markup that is generated when you double-click a Button control to add it to a WPF window.

<Button Height="23" HorizontalAlignment="Left" Margin="10,10,0,0"

Name="Button1" VerticalAlignment="Top" Width="75">Button</Button>

By default, attributes that you can modify, such as the width and height, appear in red font color. You can change the values directly in the XAML markup, as shown in the following example.

<Button Height="30" HorizontalAlignment="Left" Margin="10,10,0,0"

Name="Button1" VerticalAlignment="Top" Width="60">Submit</Button>