설명 없음

abolshakova e3b3a3516e Удалить 'NewFile2.axaml' 7 달 전
.idea af2f310ac8 1nd com 7 달 전
AvaloniaApplication1 af2f310ac8 1nd com 7 달 전
img af2f310ac8 1nd com 7 달 전
AvaloniaApplication1.sln af2f310ac8 1nd com 7 달 전
README.md 4d5afc05bf Обновить 'README.md' 7 달 전

README.md

Евгений Иванович! Извините за задержку! так получилось, что у меня не работали отдельные коды. Поэтому начало я писала в райдере, потом перешла на vs. Главное что сейчас все работает . Я счастлива

--------------------------------------------------------

Создание оконного приложения

Структура и пространства имен AXAML

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="AvaloniaApplication1.MainWindow"
        Title="AvaloniaApplication1">
    Welcome to Avalonia!
</Window>

Элементы и их атрибуты & Специальные символы

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="AvaloniaApplication1.MainWindow"
        Title="AvaloniaApplication1">
    <Button 
        Content="Тык  сюда   пж  &gt;&quot;&lt;"/>
</Window>

Взаимодействие кода C# и XAML

using Avalonia.Controls;
using Avalonia.Interactivity;
using MsBox.Avalonia;
using MsBox.Avalonia.Enums;

namespace AvaloniaApplication1;

public partial class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
    }

    private void Button1_OnClick(
        object? sender, 
        RoutedEventArgs e)
    {
        string text = textBox1.Text;
        if (text != "")
        {
            MessageBoxManager
                .GetMessageBoxStandard(
                    "Caption", 
                    text,
                    ButtonEnum.Ok)
                .ShowAsync();
        }
    }
}
<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
        x:Class="AvaloniaApplication1.MainWindow"
        Title="AvaloniaApplication1">
    <Grid>
        <TextBox 
            x:Name="textBox1" 
            Width="150" 
            Height="30" 
            VerticalAlignment="Top" 
            Margin="20" />
        <Button 
            x:Name="button1"  
            Width="100" 
            Height="30" 
            Content="Роблокс" 
            Click="Button1_OnClick" />
    </Grid>
</Window>

Пространства имен из C# в XAML

using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp1
{

    public class Phone
    {
        public string Name { get; set; }
        public int Price { get; set; }

        public override string ToString()
        {
            return $"Смартфон {this.Name}; цена: {this.Price}";
        }
    }
}
<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Button 
        x:Name="phoneButton"  
        Width="250" 
        Height="40"
    >
            <local:Phone
            Name="Lumia 950" 
            Price="700" />
        </Button>
</Window>

Компоновка

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Grid ShowGridLines="True">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Button
                Content="Строка 0 Столбец 0" Grid.ColumnSpan="2" Margin="0,0,0,144" Grid.RowSpan="2"  />
            <Button
                Grid.Column="0"
                Grid.Row="1"
                Content="Объединение трех столбцов"
                Grid.ColumnSpan="3" Margin="0,144,0,-1" Grid.RowSpan="2"  />
            <Button
                Grid.Column="1"
                Grid.Row="1"
                Content="Строка 2 Столбец 2"  />
        </Grid>
    </Grid>
</Window>


<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Button
            Grid.Column="0"
            Content="Левый глаз" Margin="76,140,250,115" />
        <GridSplitter
            Grid.Column="1"
            Width="3" />
        <Button
            Grid.Column="2"
            Content="Правый глаз" Margin="138,26,184,133" />
        <Button Margin="161,329,302,73"
                Content="ротик" Grid.ColumnSpan="3" RenderTransformOrigin="0.5,0.5" >
            <Button.RenderTransform>
                <TransformGroup>
                    <ScaleTransform/>
                    <SkewTransform/>
                    <RotateTransform Angle="-15.38"/>
                    <TranslateTransform/>
                </TransformGroup>
            </Button.RenderTransform>
        </Button>
    </Grid>
</Window>

StackPanel

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <StackPanel Orientation="Vertical">
        <Button 
        Background="Aqua" 
        MinWidth="30" 
        Content="Небо" Height="297" />
        <Button 
        Background="GreenYellow" 
        MinWidth="30" 
        Content="Травка" />
        <Button 
        Background="Brown" 
        MinWidth="30" 
        Content="Земелька" Height="119" />
    </StackPanel>
</Window>

WrapPanel

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <WrapPanel>
        <Button 
        Background="Red" 
        Content="" Height="80" Width="80
            "/>
        
        <Button 
        Background="Orange" 
        Content="" Height="80" Width="80"/>
        <Button 
            Background="Yellow" 
            Content="" Height="80" Width="80"/>
        <Button 
            Background="GreenYellow" 
            Content="" Height="80" Width="80"/>
        <Button 
            Background="Green" 
            Content="" Height="80" Width="80"/>
        <Button 
            Background="LightBlue" 
            Content="" Height="80" Width="80"/>
        <Button 
            Background="Blue" 
            Content="" Height="80" Width="80"/>
        <Button 
            Background="BlueViolet" 
            Content="" Height="80" Width="80"/>
        <Button 
            Background="Pink" 
            Content="" Height="80" Width="80"/>


    </WrapPanel>
</Window>