fix: fix Borderless TextBox pointerover style.

This commit is contained in:
rabbitism 2022-12-24 15:18:03 +08:00 committed by Dong Bin
parent 78e3dd2dc8
commit ca9e7865d3
2 changed files with 54 additions and 18 deletions

View File

@ -1,16 +1,20 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<StackPanel
Width="200" Margin="20"
Width="200"
Margin="20"
Spacing="20">
<TextBox
Classes="clearButton" Text="Hello"
Classes="clearButton"
Text="Hello"
Theme="{StaticResource BorderlessTextBox}" />
<TextBox
Classes="Large" Text="Hello"
Classes="Large"
Text="Hello"
Theme="{StaticResource BorderlessTextBox}" />
<TextBox
Classes="Small" Text="Hello"
Classes="Small"
Text="Hello"
Theme="{StaticResource BorderlessTextBox}" />
</StackPanel>
</Design.PreviewWith>
@ -25,7 +29,8 @@
<Label Background="Transparent">
<Label.Content>
<PathIcon
Width="16" Height="16"
Width="16"
Height="16"
Data="{DynamicResource TextBoxClearButtonData}"
Foreground="{TemplateBinding Foreground}" />
</Label.Content>
@ -44,11 +49,13 @@
<!-- Background must be transparent or hit test will fail -->
<Panel Background="Transparent">
<PathIcon
Width="16" Height="16"
Width="16"
Height="16"
Data="{DynamicResource PasswordBoxRevealButtonData}"
IsVisible="{Binding $parent[ToggleButton].IsChecked, Converter={x:Static BoolConverters.Not}}" />
<PathIcon
Width="16" Height="16"
Width="16"
Height="16"
Data="{DynamicResource PasswordBoxHideButtonData}"
IsVisible="{Binding $parent[ToggleButton].IsChecked}" />
</Panel>
@ -122,12 +129,14 @@
</Panel>
</ScrollViewer>
<Button
Name="PART_ClearButton" Grid.Column="2"
Name="PART_ClearButton"
Grid.Column="2"
Command="{Binding $parent[TextBox].Clear}"
IsVisible="False"
Theme="{StaticResource InputClearButton}" />
<ToggleButton
Name="PART_RevealButton" Grid.Column="3"
Name="PART_RevealButton"
Grid.Column="3"
Margin="4,0,0,0"
IsChecked="{TemplateBinding RevealPassword,
Mode=TwoWay}"
@ -183,6 +192,7 @@
<Setter Property="TextBox.BorderBrush" Value="{DynamicResource TextBoxBorderlessDefaultBorderBrush}" />
<Style Selector="^:pointerover">
<Setter Property="TextBox.Background" Value="{DynamicResource TextBoxBorderlessPointeroverBackground}" />
<Setter Property="TextBox.BorderBrush" Value="{DynamicResource TextBoxBorderlessPointeroverBorderBrush}" />
</Style>
<Style Selector="^:focus">
<Setter Property="TextBox.Background" Value="{DynamicResource TextBoxBorderlessPointeroverBackground}" />

View File

@ -1,25 +1,51 @@
<ResourceDictionary
xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=System.Runtime">
<SolidColorBrush x:Key="TextBoxDefaultBorderBrush" Color="#C6CACD" />
<SolidColorBrush x:Key="TextBoxDefaultBackground" Color="Transparent" />
<SolidColorBrush x:Key="TextBoxFocusBackground" Opacity="0.05" Color="#E6E8EA" />
<SolidColorBrush
x:Key="TextBoxFocusBackground"
Opacity="0.05"
Color="#E6E8EA" />
<SolidColorBrush x:Key="TextBoxPointerOverBorderBrush" Color="#0062D6" />
<SolidColorBrush x:Key="TextBoxFocusBorderBrush" Color="#004FB3" />
<SolidColorBrush x:Key="TextBoxForeground" Color="#1C1F23" />
<SolidColorBrush x:Key="TextBoxWatermarkForeground" Color="#1C1F23" />
<SolidColorBrush x:Key="TextBoxInnerForeground" Opacity="0.62" Color="#1C1F23" />
<SolidColorBrush
x:Key="TextBoxInnerForeground"
Opacity="0.62"
Color="#1C1F23" />
<SolidColorBrush x:Key="TextBoxButtonDefaultForeground" Opacity="0.2" Color="#2E3238" />
<SolidColorBrush x:Key="TextBoxButtonPointerOverForeground" Opacity="0.4" Color="#2E3238" />
<SolidColorBrush
x:Key="TextBoxButtonDefaultForeground"
Opacity="0.2"
Color="#2E3238" />
<SolidColorBrush
x:Key="TextBoxButtonPointerOverForeground"
Opacity="0.4"
Color="#2E3238" />
<SolidColorBrush x:Key="TextBoxDisabledBackground" Opacity="0.04" Color="#403238" />
<SolidColorBrush x:Key="TextBoxDisabledForeground" Opacity="0.35" Color="#1C1F23" />
<SolidColorBrush
x:Key="TextBoxDisabledBackground"
Opacity="0.04"
Color="#403238" />
<SolidColorBrush
x:Key="TextBoxDisabledForeground"
Opacity="0.35"
Color="#1C1F23" />
<SolidColorBrush x:Key="TextBoxDisabledBorderBrush" Color="#E6E8EA" />
<SolidColorBrush x:Key="TextBoxBorderlessDefaultBackground" Opacity="0.05" Color="#2E3238" />
<SolidColorBrush
x:Key="TextBoxBorderlessDefaultBackground"
Opacity="0.05"
Color="#2E3238" />
<SolidColorBrush x:Key="TextBoxBorderlessDefaultBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="TextBoxBorderlessPointeroverBackground" Opacity="0.09" Color="#2E3238" />
<SolidColorBrush
x:Key="TextBoxBorderlessPointeroverBackground"
Opacity="0.09"
Color="#2E3238" />
<SolidColorBrush x:Key="TextBoxBorderlessPointeroverBorderBrush" Color="Transparent" />
<sys:Double x:Key="TextBoxDefaultHeight">30</sys:Double>
<sys:Double x:Key="TextBoxSmallHeight">22</sys:Double>