Avalonia UI применение стиля
Не применяется стиль для TextBox При попытке применить стиль ничего не меняется, подскажите пожалуйста как это испаравить. Ниже представлен код на .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="Messenger.MainWindow"
Title="Messenger"
Background="White">
<StackPanel Margin="10"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<TextBlock Text="Регистрация"
FontSize="20"
FontWeight="Bold"
HorizontalAlignment="Center"
Margin="0,0,0,20"
VerticalAlignment="Top"
Foreground="Black"/>
<StackPanel Margin="0,0,0,10">
<TextBlock
Text="Имя пользователя:"
FontWeight="Bold"
Margin="0,0,0,5"
Foreground="Black"/>
<TextBox
BorderBrush="Gray"
BorderThickness="1"
Background="White"
x:Name="UsernameTextBox"
Watermark="Введите имя"
Foreground="Black"/>
</StackPanel>
<StackPanel Margin="0,0,0,10">
<TextBlock
Text="Электронная почта:"
FontWeight="Bold"
Margin="0,0,0,5"
Foreground="Black"/>
<TextBox
BorderBrush="Gray"
BorderThickness="1"
Background="White"
x:Name="EmailTextBox"
Watermark="Введите email"
Foreground="Black">
</TextBox>
</StackPanel>
<StackPanel Margin="0,0,0,10">
<TextBlock
Text="Пароль:"
FontWeight="Bold"
Margin="0,0,0,5"
Foreground="Black"/>
<TextBox
x:Name="PasswordTextBox"
BorderBrush="Gray"
BorderThickness="1"
Background="White"
Watermark="Введите пароль"
PasswordChar="*"
Foreground="Black">
<TextBox.Styles>
<!-- Прямое переопределение состояния focus -->
<Style Selector="TextBox:focus">
<Setter Property="Background" Value="White" />
</Style>
</TextBox.Styles>
</TextBox>
</StackPanel>
<Button
Content="Зарегистрироваться"
Height="40"
HorizontalAlignment="Stretch"
Click="RegisterButton_Click"
Background="#9421db"
Foreground="White"/>
</StackPanel>
</Window>
Ответы (1 шт):
Автор решения: Mikhail
→ Ссылка
Тут следует обращаться к стилю используя полный пут к этому элементу. В следующий раз можно смотреть документацию по контролам, там все есть.
<Style Selector="TextBox:focus">
<Style Selector="^ /template/ Border#PART_BorderElement">
<Setter Property="Background" Value="#f9b410"/>
</Style>
</Style>