feat: unify MinHeight based on TextBox.

This commit is contained in:
Zhang Dian 2024-03-20 15:20:48 +08:00
parent 07278047a4
commit f1d87f7c4d
6 changed files with 24 additions and 25 deletions

View File

@ -10,6 +10,7 @@
</Design.PreviewWith> </Design.PreviewWith>
<ControlTheme x:Key="{x:Type AutoCompleteBox}" TargetType="AutoCompleteBox"> <ControlTheme x:Key="{x:Type AutoCompleteBox}" TargetType="AutoCompleteBox">
<Setter Property="AutoCompleteBox.VerticalAlignment" Value="Center" /> <Setter Property="AutoCompleteBox.VerticalAlignment" Value="Center" />
<Setter Property="AutoCompleteBox.MinHeight" Value="{DynamicResource AutoCompleteBoxDefaultHeight}" />
<Setter Property="AutoCompleteBox.MaxDropDownHeight" Value="{DynamicResource AutoCompleteMaxDropdownHeight}" /> <Setter Property="AutoCompleteBox.MaxDropDownHeight" Value="{DynamicResource AutoCompleteMaxDropdownHeight}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="AutoCompleteBox"> <ControlTemplate TargetType="AutoCompleteBox">
@ -17,7 +18,8 @@
<Panel> <Panel>
<TextBox <TextBox
Name="PART_TextBox" Name="PART_TextBox"
VerticalAlignment="Center" VerticalAlignment="Stretch"
MinHeight="0"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
Theme="{DynamicResource NonErrorTextBox}" Theme="{DynamicResource NonErrorTextBox}"
InnerLeftContent="{TemplateBinding InnerLeftContent}" InnerLeftContent="{TemplateBinding InnerLeftContent}"
@ -56,7 +58,8 @@
<Panel> <Panel>
<TextBox <TextBox
Name="PART_TextBox" Name="PART_TextBox"
VerticalAlignment="Center" VerticalAlignment="Stretch"
MinHeight="0"
Classes="Bordered" Classes="Bordered"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
Watermark="{TemplateBinding Watermark}" /> Watermark="{TemplateBinding Watermark}" />
@ -86,15 +89,11 @@
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </Style>
<Style Selector="^.Large /template/ TextBox"> <Style Selector="^.Large">
<Setter Property="MinHeight" Value="{DynamicResource AutoCompleteBoxLargeHeight}" /> <Setter Property="MinHeight" Value="{DynamicResource AutoCompleteBoxLargeHeight}" />
</Style> </Style>
<Style Selector="^.Small /template/ TextBox"> <Style Selector="^.Small">
<Setter Property="MinHeight" Value="{DynamicResource AutoCompleteBoxSmallHeight}" /> <Setter Property="MinHeight" Value="{DynamicResource AutoCompleteBoxSmallHeight}" />
</Style> </Style>
</ControlTheme> </ControlTheme>
</ResourceDictionary> </ResourceDictionary>

View File

@ -16,6 +16,7 @@
<Setter Property="HorizontalContentAlignment" Value="Left" /> <Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" /> <Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="8 0" /> <Setter Property="Padding" Value="8 0" />
<Setter Property="MinHeight" Value="{DynamicResource CalendarDatePickerDefaultHeight}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="CalendarDatePicker"> <ControlTemplate TargetType="CalendarDatePicker">
<DataValidationErrors> <DataValidationErrors>
@ -38,7 +39,7 @@
Name="PART_TextBox" Name="PART_TextBox"
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="2" Grid.ColumnSpan="2"
MinHeight="{DynamicResource CalendarDatePickerDefaultHeight}" MinHeight="0"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
@ -129,14 +130,10 @@
</Style> </Style>
<Style Selector="^.Large"> <Style Selector="^.Large">
<Style Selector="^ /template/ TextBox#PART_TextBox"> <Setter Property="MinHeight" Value="{DynamicResource CalendarDatePickerLargeHeight}" />
<Setter Property="MinHeight" Value="{DynamicResource CalendarDatePickerInnerLargeHeight}" />
</Style>
</Style> </Style>
<Style Selector="^.Small"> <Style Selector="^.Small">
<Style Selector="^ /template/ TextBox#PART_TextBox"> <Setter Property="MinHeight" Value="{DynamicResource CalendarDatePickerSmallHeight}" />
<Setter Property="MinHeight" Value="{DynamicResource CalendarDatePickerInnerSmallHeight}" />
</Style>
</Style> </Style>
<Style Selector="^:pointerover"> <Style Selector="^:pointerover">

View File

@ -7,6 +7,7 @@
<Setter Property="NumericUpDown.VerticalAlignment" Value="Center" /> <Setter Property="NumericUpDown.VerticalAlignment" Value="Center" />
<Setter Property="NumericUpDown.VerticalContentAlignment" Value="Center" /> <Setter Property="NumericUpDown.VerticalContentAlignment" Value="Center" />
<Setter Property="NumericUpDown.CornerRadius" Value="{DynamicResource NumericUpDownCornerRadius}" /> <Setter Property="NumericUpDown.CornerRadius" Value="{DynamicResource NumericUpDownCornerRadius}" />
<Setter Property="NumericUpDown.MinHeight" Value="{DynamicResource NumericUpDownDefaultHeight}" />
<Setter Property="NumericUpDown.Template"> <Setter Property="NumericUpDown.Template">
<ControlTemplate TargetType="NumericUpDown"> <ControlTemplate TargetType="NumericUpDown">
<DataValidationErrors> <DataValidationErrors>
@ -24,7 +25,8 @@
<TextBox <TextBox
Name="PART_TextBox" Name="PART_TextBox"
Height="{TemplateBinding Height}" Height="{TemplateBinding Height}"
MinHeight="{DynamicResource NumericUpDownWrapperDefaultHeight}" MinHeight="0"
VerticalAlignment="Stretch"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
AcceptsReturn="False" AcceptsReturn="False"
@ -44,11 +46,11 @@
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Style Selector="^.Large /template/ TextBox#PART_TextBox"> <Style Selector="^.Large">
<Setter Property="MinHeight" Value="{DynamicResource NumericUpDownWrapperLargeHeight}" /> <Setter Property="MinHeight" Value="{DynamicResource NumericUpDownLargeHeight}" />
</Style> </Style>
<Style Selector="^.Small /template/ TextBox#PART_TextBox"> <Style Selector="^.Small">
<Setter Property="MinHeight" Value="{DynamicResource NumericUpDownWrapperSmallHeight}" /> <Setter Property="MinHeight" Value="{DynamicResource NumericUpDownSmallHeight}" />
</Style> </Style>
<Style Selector="^:error"> <Style Selector="^:error">

View File

@ -2,6 +2,7 @@
<Thickness x:Key="AutoCompleteBoxPopupBorderThickness">1</Thickness> <Thickness x:Key="AutoCompleteBoxPopupBorderThickness">1</Thickness>
<Thickness x:Key="AutoCompleteBoxPopupMargin">4</Thickness> <Thickness x:Key="AutoCompleteBoxPopupMargin">4</Thickness>
<CornerRadius x:Key="AutoCompleteBoxPopupCornerRadius">6</CornerRadius> <CornerRadius x:Key="AutoCompleteBoxPopupCornerRadius">6</CornerRadius>
<x:Double x:Key="AutoCompleteBoxDefaultHeight">32</x:Double>
<x:Double x:Key="AutoCompleteBoxSmallHeight">24</x:Double> <x:Double x:Key="AutoCompleteBoxSmallHeight">24</x:Double>
<x:Double x:Key="AutoCompleteBoxLargeHeight">40</x:Double> <x:Double x:Key="AutoCompleteBoxLargeHeight">40</x:Double>
<x:Double x:Key="AutoCompleteMaxDropdownHeight">600</x:Double> <x:Double x:Key="AutoCompleteMaxDropdownHeight">600</x:Double>

View File

@ -2,7 +2,7 @@
<PathGeometry x:Key="CalendarDatePickerIconGlyph">M4 20V8H20V20H4ZM2 4C2 2.89543 2.89543 2 4 2H20C21.1046 2 22 2.89543 22 4V20C22 21.1046 21.1046 22 20 22H4C2.89543 22 2 21.1046 2 20V4ZM6 10.5C6 10.2239 6.22386 10 6.5 10H8.5C8.77614 10 9 10.2239 9 10.5V12.5C9 12.7761 8.77614 13 8.5 13H6.5C6.22386 13 6 12.7761 6 12.5V10.5ZM6.5 15C6.22386 15 6 15.2239 6 15.5V17.5C6 17.7761 6.22386 18 6.5 18H8.5C8.77614 18 9 17.7761 9 17.5V15.5C9 15.2239 8.77614 15 8.5 15H6.5ZM10.5 10.5C10.5 10.2239 10.7239 10 11 10H13C13.2761 10 13.5 10.2239 13.5 10.5V12.5C13.5 12.7761 13.2761 13 13 13H11C10.7239 13 10.5 12.7761 10.5 12.5V10.5ZM11 15C10.7239 15 10.5 15.2239 10.5 15.5V17.5C10.5 17.7761 10.7239 18 11 18H13C13.2761 18 13.5 17.7761 13.5 17.5V15.5C13.5 15.2239 13.2761 15 13 15H11ZM15 10.5C15 10.2239 15.2239 10 15.5 10H17.5C17.7761 10 18 10.2239 18 10.5V12.5C18 12.7761 17.7761 13 17.5 13H15.5C15.2239 13 15 12.7761 15 12.5V10.5ZM15.5 15C15.2239 15 15 15.2239 15 15.5V17.5C15 17.7761 15.2239 18 15.5 18H17.5C17.7761 18 18 17.7761 18 17.5V15.5C18 15.2239 17.7761 15 17.5 15H15.5Z</PathGeometry> <PathGeometry x:Key="CalendarDatePickerIconGlyph">M4 20V8H20V20H4ZM2 4C2 2.89543 2.89543 2 4 2H20C21.1046 2 22 2.89543 22 4V20C22 21.1046 21.1046 22 20 22H4C2.89543 22 2 21.1046 2 20V4ZM6 10.5C6 10.2239 6.22386 10 6.5 10H8.5C8.77614 10 9 10.2239 9 10.5V12.5C9 12.7761 8.77614 13 8.5 13H6.5C6.22386 13 6 12.7761 6 12.5V10.5ZM6.5 15C6.22386 15 6 15.2239 6 15.5V17.5C6 17.7761 6.22386 18 6.5 18H8.5C8.77614 18 9 17.7761 9 17.5V15.5C9 15.2239 8.77614 15 8.5 15H6.5ZM10.5 10.5C10.5 10.2239 10.7239 10 11 10H13C13.2761 10 13.5 10.2239 13.5 10.5V12.5C13.5 12.7761 13.2761 13 13 13H11C10.7239 13 10.5 12.7761 10.5 12.5V10.5ZM11 15C10.7239 15 10.5 15.2239 10.5 15.5V17.5C10.5 17.7761 10.7239 18 11 18H13C13.2761 18 13.5 17.7761 13.5 17.5V15.5C13.5 15.2239 13.2761 15 13 15H11ZM15 10.5C15 10.2239 15.2239 10 15.5 10H17.5C17.7761 10 18 10.2239 18 10.5V12.5C18 12.7761 17.7761 13 17.5 13H15.5C15.2239 13 15 12.7761 15 12.5V10.5ZM15.5 15C15.2239 15 15 15.2239 15 15.5V17.5C15 17.7761 15.2239 18 15.5 18H17.5C17.7761 18 18 17.7761 18 17.5V15.5C18 15.2239 17.7761 15 17.5 15H15.5Z</PathGeometry>
<Thickness x:Key="CalendarDatePickerBorderThickness">1</Thickness> <Thickness x:Key="CalendarDatePickerBorderThickness">1</Thickness>
<CornerRadius x:Key="CalendarDatePickerCornerRadius">3</CornerRadius> <CornerRadius x:Key="CalendarDatePickerCornerRadius">3</CornerRadius>
<x:Double x:Key="CalendarDatePickerInnerSmallHeight">24</x:Double>
<x:Double x:Key="CalendarDatePickerInnerLargeHeight">40</x:Double>
<x:Double x:Key="CalendarDatePickerDefaultHeight">32</x:Double> <x:Double x:Key="CalendarDatePickerDefaultHeight">32</x:Double>
<x:Double x:Key="CalendarDatePickerSmallHeight">24</x:Double>
<x:Double x:Key="CalendarDatePickerLargeHeight">40</x:Double>
</ResourceDictionary> </ResourceDictionary>

View File

@ -1,6 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<CornerRadius x:Key="NumericUpDownCornerRadius">3</CornerRadius> <CornerRadius x:Key="NumericUpDownCornerRadius">3</CornerRadius>
<x:Double x:Key="NumericUpDownWrapperDefaultHeight">32</x:Double> <x:Double x:Key="NumericUpDownDefaultHeight">32</x:Double>
<x:Double x:Key="NumericUpDownWrapperSmallHeight">24</x:Double> <x:Double x:Key="NumericUpDownSmallHeight">24</x:Double>
<x:Double x:Key="NumericUpDownWrapperLargeHeight">40</x:Double> <x:Double x:Key="NumericUpDownLargeHeight">40</x:Double>
</ResourceDictionary> </ResourceDictionary>