feat: redesign TextBox.

This commit is contained in:
Zhang Dian 2024-03-11 19:16:56 +08:00
parent c2d1d0c4eb
commit 46e57925b9
3 changed files with 18 additions and 1 deletions

View File

@ -10,6 +10,18 @@
mc:Ignorable="d">
<ScrollViewer>
<StackPanel HorizontalAlignment="Left" Spacing="20">
<StackPanel Orientation="Horizontal">
<TextBox Classes="Large" Width="150"/>
<TextBox Width="150"/>
<TextBox Classes="Small" Width="150"/>
</StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox IsEnabled="False" Width="150"/>
<TextBox Classes="Bordered" Width="150"/>
<TextBox Classes="Bordered" IsEnabled="False" Width="150"/>
</StackPanel>
<TextBox Width="300" />
<TextBox Width="300" Classes="Large" />
<TextBox Width="300" Classes="Small" />

View File

@ -53,11 +53,13 @@
<Setter Property="TextBox.SelectionBrush" Value="{DynamicResource TextBoxSelectionBackground}" />
<Setter Property="TextBox.SelectionForegroundBrush" Value="{DynamicResource TextBoxSelectionForeground}" />
<Setter Property="TextBox.BorderThickness" Value="{DynamicResource TextBoxBorderThickness}" />
<Setter Property="TextBox.BackgroundSizing" Value="OuterBorderEdge" />
<Setter Property="TextBox.CornerRadius" Value="{DynamicResource TextBoxDefaultCornerRadius}" />
<Setter Property="TextBox.FontSize" Value="14" />
<Setter Property="TextBox.Cursor" Value="Ibeam" />
<Setter Property="TextBox.CaretBrush" Value="{DynamicResource TextBoxTextCaretBrush}" />
<Setter Property="TextBox.Padding" Value="{DynamicResource TextBoxContentPadding}" />
<Setter Property="TextBox.VerticalAlignment" Value="Center" />
<Setter Property="TextBox.VerticalContentAlignment" Value="Center" />
<Setter Property="TextBox.FocusAdorner" Value="{x:Null}" />
<Setter Property="ScrollViewer.IsScrollChainingEnabled" Value="True" />
@ -69,6 +71,7 @@
Name="PART_ContentPresenterBorder"
MinHeight="{DynamicResource TextBoxWrapperDefaultHeight}"
Background="{TemplateBinding Background}"
BackgroundSizing="{TemplateBinding BackgroundSizing}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
@ -243,6 +246,7 @@
<Setter Property="TextBox.BorderBrush" Value="{DynamicResource TextBoxDefaultBorderBrush}" />
<Setter Property="TextBox.SelectionBrush" Value="{DynamicResource TextBoxSelectionBackground}" />
<Setter Property="TextBox.SelectionForegroundBrush" Value="{DynamicResource TextBoxSelectionForeground}" />
<Setter Property="TextBox.BackgroundSizing" Value="OuterBorderEdge" />
<Setter Property="TextBox.BorderThickness" Value="{DynamicResource TextBoxBorderThickness}" />
<Setter Property="TextBox.CornerRadius" Value="{DynamicResource TextBoxDefaultCornerRadius}" />
<Setter Property="TextBox.FontSize" Value="14" />
@ -250,6 +254,7 @@
<Setter Property="TextBox.CaretBrush" Value="{DynamicResource TextBoxTextCaretBrush}" />
<Setter Property="TextBox.Padding" Value="{DynamicResource TextBoxContentPadding}" />
<Setter Property="TextBox.MinHeight" Value="{DynamicResource TextBoxWrapperDefaultHeight}" />
<Setter Property="TextBox.VerticalAlignment" Value="Center" />
<Setter Property="TextBox.VerticalContentAlignment" Value="Center" />
<Setter Property="TextBox.FocusAdorner" Value="{x:Null}" />
<Setter Property="ScrollViewer.IsScrollChainingEnabled" Value="True" />
@ -261,6 +266,7 @@
Name="PART_ContentPresenterBorder"
MinHeight="{TemplateBinding MinHeight}"
Background="{TemplateBinding Background}"
BackgroundSizing="{TemplateBinding BackgroundSizing}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">

View File

@ -1,5 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<x:Double x:Key="TextBoxSmallHeight">22</x:Double>
<x:Double x:Key="TextBoxWrapperDefaultHeight">32</x:Double>
<x:Double x:Key="TextBoxWrapperSmallHeight">24</x:Double>
<x:Double x:Key="TextBoxWrapperLargeHeight">40</x:Double>