Skip to content

Commit afec674

Browse files
authored
Merge pull request #606 from GamerVII-NET/features/introduction-to-xaml
[RU] Translation of the "Avalonia XAML" page
2 parents 1a9a276 + 6dc444b commit afec674

File tree

1 file changed

+44
-65
lines changed

1 file changed

+44
-65
lines changed

i18n/ru/docusaurus-plugin-content-docs/current/basics/user-interface/introduction-to-xaml.md

Lines changed: 44 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,22 @@ description: CONCEPTS
44

55
# Avalonia XAML
66

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, который применяется во многих фреймворках пользовательского интерфейса.
88

99
:::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, вы можете обратиться к следующим ресурсам:
1111

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+
:::
1515

16-
## AXAML File Extension
16+
## Расширение файлов AXAML
1717

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.
1919

20-
## File Format
20+
## Формат файла
2121

22-
A typical Avalonia XAML file looks like this:
22+
Пример файла Avalonia XAML:
2323

2424
```xml
2525
<Window xmlns="https://github.com/avaloniaui"
@@ -28,27 +28,27 @@ A typical Avalonia XAML file looks like this:
2828
</Window>
2929
```
3030

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, в данном случае окну.
3232

33-
The sample above uses three interesting attributes:
33+
Пример выше использует три важных атрибута:
3434

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).
3838

3939
:::info
40-
For information about the code-behind concept, see [here](code-behind).
40+
Подробнее о концепции "code-behind" можно прочитать [здесь](code-behind).
4141
:::
4242

43-
## Control Elements
43+
## Элементы управления
4444

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_. Имя элемента совпадает с именем класса контрола.
4646

4747
:::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).
4949
:::
5050

51-
For example, this XAML adds a button to the content of a window:
51+
Например, следующий код добавляет кнопку в окно:
5252

5353
```xml
5454
<Window xmlns="https://github.com/avaloniaui"
@@ -58,14 +58,14 @@ For example, this XAML adds a button to the content of a window:
5858
```
5959

6060
:::info
61-
For a complete list of the _Avalonia UI_ built-in controls, see the reference [here](../../reference/controls).
61+
Список встроенных контролов Avalonia UI можно найти [здесь](../../reference/controls).
6262
:::
6363

64-
## Control Attributes
64+
## Атрибуты элементов управления
6565

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-элементов соответствуют свойствам контролов. Свойства можно задать, добавляя атрибуты к элементам.
6767

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`:
6969

7070
```xml
7171
<Window xmlns="https://github.com/avaloniaui"
@@ -74,9 +74,9 @@ For example, to specify a blue background for a button control, you add the `Bac
7474
</Window>
7575
```
7676

77-
## Control Content
77+
## Содержимое элементов управления
7878

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`:
8080

8181
```xml
8282
<Window xmlns="https://github.com/avaloniaui"
@@ -85,11 +85,11 @@ You might have noticed that the button in the above sample has its content (the
8585
</Window>
8686
```
8787

88-
This behaviour is specific to the content of an _Avalonia UI_ control.
88+
Это поведение характерно для содержимого элементов управления в _Avalonia UI_.
8989

90-
## Data Binding
90+
## Привязка данных
9191

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}`. Например:
9393

9494
```xml
9595
<Window xmlns="https://github.com/avaloniaui"
@@ -99,67 +99,46 @@ You will often use the _Avalonia UI_ binding system to link a control property t
9999
```
100100

101101
:::info
102-
For further information about the concept behind data binding, see [here](../data/data-binding).
102+
Подробнее о концепции привязки данных можно прочитать [здесь](../data/data-binding).
103103
:::
104104

105-
## Code-behind Files
105+
## Файлы "code-behind"
106106

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`.
108108

109109
:::info
110-
For guidance about programming using code-behind files, see [here](code-behind).
110+
Руководство по программированию с использованием "code-behind" доступно [здесь](code-behind).
111111
:::
112112

113-
## XML Namespaces
113+
## Пространства имён XML
114114

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 находить определения элементов.
116116

117117
:::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).
119119
:::
120120

121-
You can add a namespace using the `xmlns` attribute. The format of a namespace declaration is as follows:
121+
Пространства имён добавляются с помощью атрибута `xmlns`. Формат объявления:
122122

123123
```xml
124124
xmlns:alias="definition"
125125
```
126126

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+
Чаще всего пространства имён объявляют в корневом элементе.
138128

139-
### **CLR Namespace Prefix**
129+
### **Префикс CLR Namespace**
140130

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:
144-
145-
```xml
146-
<Window ...
147-
xmlns:myAlias1="clr-namespace:MyNamespace.AppNameSpace.UI"
148-
... >
149-
```
150-
151-
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:`:
152132

153133
```xml
154-
<Window ...
155-
xmlns:myAlias2="clr-namespace:MyNameSpace.OtherAssembly;assembly=OtherAssembly"
156-
... >
134+
xmlns:myAlias1="clr-namespace:MyNamespace.AppNameSpace.UI"
135+
xmlns:myAlias2="clr-namespace:MyNamespace.OtherAssembly;assembly=OtherAssembly"
157136
```
158137

159-
### **Using Prefix**
138+
### **Префикс Using**
160139

161-
There is an alternative prefix `using:` that you can use to reference code in the current assembly. For example:
140+
Альтернативный префикс `using:` позволяет ссылаться на код в текущей сборке:
162141

163142
```xml
164143
xmlns:myAlias3="using:MyNamespace.AppNameSpace.UI"
165-
```
144+
```

0 commit comments

Comments
 (0)