You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: i18n/ru/docusaurus-plugin-content-docs/current/basics/user-interface/introduction-to-xaml.md
+44-65Lines changed: 44 additions & 65 deletions
Original file line number
Diff line number
Diff line change
@@ -4,22 +4,22 @@ description: CONCEPTS
4
4
5
5
# Avalonia XAML
6
6
7
-
_Avalonia UI_uses XAML to define a user interface. XAML is an XML-based mark-up language that is used by many UI frameworks.
7
+
_Avalonia UI_использует XAML для описания пользовательского интерфейса. XAML — это язык разметки, основанный на XML, который применяется во многих фреймворках пользовательского интерфейса.
8
8
9
9
:::info
10
-
These pages will introduce you to how XAML is used specifically in _Avalonia UI_. For background information about how XAML is used elsewhere in Microsoft technologies, you can use these references:
10
+
На этих страницах вы узнаете, как именно XAML используется в _Avalonia UI_. Для получения общей информации о применении XAML в других технологиях Microsoft, вы можете обратиться к следующим ресурсам:
11
11
12
-
* Microsoft XAML documentation for WPF, see [here](https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/xaml-overview-wpf).
13
-
* Microsoft XAML documentation for UWP, see [here](https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/xaml-overview).
14
-
:::
12
+
- Документация по XAML в WPF: [ссылка](https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/xaml-overview-wpf).
13
+
- Документация по XAML в UWP: [ссылка](https://docs.microsoft.com/en-us/windows/uwp/xaml-platform/xaml-overview).
14
+
:::
15
15
16
-
## AXAML File Extension
16
+
## Расширение файлов AXAML
17
17
18
-
The file extension for XAML files used elsewhere is`.xaml` but due to technical issues integrating with Visual Studio, _Avalonia UI_uses its own`.axaml`extension - 'Avalonia XAML'.
18
+
В то время как стандартное расширение файлов XAML —`.xaml`, в _Avalonia UI_используется собственное расширение`.axaml`(Avalonia XAML) из-за технических особенностей интеграции с Visual Studio.
19
19
20
-
## File Format
20
+
## Формат файла
21
21
22
-
A typical Avalonia XAML file looks like this:
22
+
Пример файла Avalonia XAML:
23
23
24
24
```xml
25
25
<Windowxmlns="https://github.com/avaloniaui"
@@ -28,27 +28,27 @@ A typical Avalonia XAML file looks like this:
28
28
</Window>
29
29
```
30
30
31
-
In common with all XML files, there is a root element. The root element tag`<Window></Window>` defines the type of the root. This will correspond to a type of Avalonia UI control, in the above example a window.
31
+
Как и в любом XML-документе, в файле есть корневой элемент. В данном примере это`<Window></Window>`, который определяет тип корневого элемента. Этот элемент соответствует определённому контролу Avalonia UI, в данном случае окну.
32
32
33
-
The sample above uses three interesting attributes:
33
+
Пример выше использует три важных атрибута:
34
34
35
-
*`xmlns="https://github.com/avaloniaui"`- this is the XAML namespace declaration for _Avalonia UI_ itself. This is required, without it the file will not be recognised as an Avalonia XAML document.
36
-
*`xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"`- this is the declaration for the XAML language namespace.
37
-
*`x:Class="AvaloniaApplication1.MainWindow"`- this is an extension of the above declaration (for 'x') that tells the XAML compiler where to find the associated class for this file. The class is defined in a code-behind file, usually written in C#.
35
+
-`xmlns="https://github.com/avaloniaui"`— объявляет пространство имён XAML для _Avalonia UI_. Без него файл не будет распознан как документ Avalonia XAML.
36
+
-`xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"`— объявляет пространство имён для языка XAML.
37
+
-`x:Class="AvaloniaApplication1.MainWindow"`— указывает XAML-компилятору, где находится связанный класс для данного файла. Этот класс обычно описывается в C#-файле (code-behind).
38
38
39
39
:::info
40
-
For information about the code-behind concept, see [here](code-behind).
40
+
Подробнее о концепции "code-behind" можно прочитать [здесь](code-behind).
41
41
:::
42
42
43
-
## Control Elements
43
+
## Элементы управления
44
44
45
-
You can compose a UI for your application by adding XML elements that represent one of the _Avalonia UI_ controls. The element tag uses the same name as the control class name.
45
+
Вы можете создать пользовательский интерфейс (UI), добавляя XML-элементы, представляющие элементы управления _Avalonia UI_. Имя элемента совпадает с именем класса контрола.
46
46
47
47
:::info
48
-
A UI can be composed of several different types of control. To learn more about the concept of UI composition, see [here](../../concepts/ui-composition.md).
48
+
Интерфейс может состоять из множества разных элементов управления. Подробнее о создании сложного интерфейса можно прочитать [здесь](../../concepts/ui-composition.md).
49
49
:::
50
50
51
-
For example, this XAML adds a button to the content of a window:
51
+
Например, следующий код добавляет кнопку в окно:
52
52
53
53
```xml
54
54
<Windowxmlns="https://github.com/avaloniaui"
@@ -58,14 +58,14 @@ For example, this XAML adds a button to the content of a window:
58
58
```
59
59
60
60
:::info
61
-
For a complete list of the _Avalonia UI_ built-in controls, see the reference [here](../../reference/controls).
61
+
Список встроенных контролов Avalonia UI можно найти [здесь](../../reference/controls).
62
62
:::
63
63
64
-
## Control Attributes
64
+
## Атрибуты элементов управления
65
65
66
-
The XML elements that represent controls have attributes corresponding to control properties that can be set. You can set a control property by adding an attribute to an element.
66
+
Атрибуты XML-элементов соответствуют свойствам контролов. Свойства можно задать, добавляя атрибуты к элементам.
67
67
68
-
For example, to specify a blue background for a button control, you add the `Background` attribute set the value to `"Blue"`. Like this:
68
+
Например, чтобы задать синий фон для кнопки, добавьте атрибут `Background`:
69
69
70
70
```xml
71
71
<Windowxmlns="https://github.com/avaloniaui"
@@ -74,9 +74,9 @@ For example, to specify a blue background for a button control, you add the `Bac
74
74
</Window>
75
75
```
76
76
77
-
## Control Content
77
+
## Содержимое элементов управления
78
78
79
-
You might have noticed that the button in the above sample has its content (the 'Hello World' string) placed between its opening and closing tags. As an alternative, you can set the content attribute, as follows:
79
+
Содержимое кнопки в примере выше задаётся строкой "Hello World!", расположенной между открывающим и закрывающим тегами. Альтернативный способ — использование атрибута `Content`:
80
80
81
81
```xml
82
82
<Windowxmlns="https://github.com/avaloniaui"
@@ -85,11 +85,11 @@ You might have noticed that the button in the above sample has its content (the
85
85
</Window>
86
86
```
87
87
88
-
This behaviour is specific to the content of an _Avalonia UI_ control.
88
+
Это поведение характерно для содержимого элементов управления в _Avalonia UI_.
89
89
90
-
## Data Binding
90
+
## Привязка данных
91
91
92
-
You will often use the _Avalonia UI_binding system to link a control property to an underlying object. The link is declared using the`{Binding}` mark-up extension. For example:
92
+
Система привязки данных _Avalonia UI_позволяет связывать свойства элементов управления с объектами. Это делается с помощью расширения разметки`{Binding}`. Например:
93
93
94
94
```xml
95
95
<Windowxmlns="https://github.com/avaloniaui"
@@ -99,67 +99,46 @@ You will often use the _Avalonia UI_ binding system to link a control property t
99
99
```
100
100
101
101
:::info
102
-
For further information about the concept behind data binding, see [here](../data/data-binding).
102
+
Подробнее о концепции привязки данных можно прочитать [здесь](../data/data-binding).
103
103
:::
104
104
105
-
## Code-behind Files
105
+
## Файлы "code-behind"
106
106
107
-
Many XAML files also have an associated code-behind file that is usually written in C#, and has the file extension`.xaml.cs`.
107
+
Многие файлы XAML имеют связанный файл "code-behind", обычно написанный на C#, с расширением`.xaml.cs`.
108
108
109
109
:::info
110
-
For guidance about programming using code-behind files, see [here](code-behind).
110
+
Руководство по программированию с использованием "code-behind" доступно [здесь](code-behind).
111
111
:::
112
112
113
-
## XML Namespaces
113
+
## Пространства имён XML
114
114
115
-
In common with any XML format, in Avalonia XAML files you can declare namespaces. This allows the XML processor to find the definitions of the elements in the file.
115
+
В Avalonia XAML можно объявлять пространства имён, как и в любом XML-документе. Это позволяет процессору XML находить определения элементов.
116
116
117
117
:::info
118
-
For background information, see the Microsoft XML namespaces documentation [here](https://docs.microsoft.com/en-us/dotnet/standard/data/xml/managing-namespaces-in-an-xml-document).
118
+
Подробнее о пространствах имён XML читайте в [документации Microsoft](https://docs.microsoft.com/en-us/dotnet/standard/data/xml/managing-namespaces-in-an-xml-document).
119
119
:::
120
120
121
-
You can add a namespace using the `xmlns` attribute. The format of a namespace declaration is as follows:
121
+
Пространства имён добавляются с помощью атрибута `xmlns`. Формат объявления:
122
122
123
123
```xml
124
124
xmlns:alias="definition"
125
125
```
126
126
127
-
It is standard practice to define all the namespaces you are going to use in the root element.
128
-
129
-
Only one namespace in a file can be defined without using the alias part of the attribute name. The alias must always be unique with in a file.
130
-
131
-
The definition part of the namespace declaration can be either a URL or a code definition. Both of these are used to locate the definition of the elements in the file.
132
-
133
-
:::info
134
-
For detailed guidance on how namespace declarations work, see [here](../../guides/custom-controls/how-to-create-a-custom-controls-library.md).
135
-
:::
136
-
137
-
There are two valid syntax options for the definition part of a XAML namespace attribute that references code:
127
+
Чаще всего пространства имён объявляют в корневом элементе.
138
128
139
-
### **CLR Namespace Prefix**
129
+
### **Префикс CLR Namespace**
140
130
141
-
There is a prefix `clr-namespace:` you can use to reference both code in the current assembly and code in a referenced assembly.
142
-
143
-
For example, when the code is present in the same assembly as the XAML, you can use this syntax:
And if the code is in another referenced assembly (for example in a library), you must extend the description to include the name of the referenced assembly:
131
+
Для ссылок на код в текущей или подключённой сборке используется префикс `clr-namespace:`:
0 commit comments