fix: ClearButton will take the icon place when TextBox has value.

This commit is contained in:
Zhang Dian 2024-08-07 16:17:22 +08:00
parent 4b71b18e72
commit 7a6c42e106
2 changed files with 13 additions and 7 deletions

View File

@ -76,7 +76,7 @@
</TextBox> </TextBox>
<Button <Button
Name="ClearButton" Name="ClearButton"
Grid.Column="1" Grid.Column="2"
Padding="0,0,8,0" Padding="0,0,8,0"
Content="{DynamicResource IconButtonClearData}" Content="{DynamicResource IconButtonClearData}"
Command="{Binding $parent[CalendarDatePicker].Clear}" Command="{Binding $parent[CalendarDatePicker].Clear}"
@ -122,10 +122,13 @@
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Style Selector="^.clearButton, ^.ClearButton"> <Style Selector="^.clearButton, ^.ClearButton">
<Style Selector="^:pointerover /template/ Button#ClearButton"> <Style Selector="^:pointerover /template/ Button#ClearButton">
<Setter Property="IsVisible" Value="{Binding $parent[CalendarDatePicker].SelectedDate, Converter={x:Static ObjectConverters.IsNotNull}}"></Setter> <Setter Property="IsVisible" Value="{Binding $parent[CalendarDatePicker].SelectedDate, Converter={x:Static ObjectConverters.IsNotNull}}" />
</Style>
<Style Selector="^:pointerover /template/ Button#PART_Button">
<Setter Property="IsVisible" Value="{Binding $parent[CalendarDatePicker].SelectedDate, Converter={x:Static ObjectConverters.IsNull}}" />
</Style> </Style>
</Style> </Style>

View File

@ -46,11 +46,11 @@
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="ComboBox"> <ControlTemplate TargetType="ComboBox">
<DataValidationErrors> <DataValidationErrors>
<Grid ColumnDefinitions="*, Auto, 32"> <Grid ColumnDefinitions="*, 32">
<Border <Border
x:Name="Background" x:Name="Background"
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="3" Grid.ColumnSpan="2"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BackgroundSizing="{TemplateBinding BackgroundSizing}" BackgroundSizing="{TemplateBinding BackgroundSizing}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
@ -86,7 +86,7 @@
Theme="{DynamicResource InnerIconButton}" /> Theme="{DynamicResource InnerIconButton}" />
<Border <Border
x:Name="DropDownOverlay" x:Name="DropDownOverlay"
Grid.Column="2" Grid.Column="1"
Width="30" Width="30"
Margin="0,1,1,1" Margin="0,1,1,1"
HorizontalAlignment="Right" HorizontalAlignment="Right"
@ -95,7 +95,7 @@
<PathIcon <PathIcon
x:Name="DropDownGlyph" x:Name="DropDownGlyph"
Grid.Column="2" Grid.Column="1"
Width="12" Width="12"
Height="12" Height="12"
Margin="0,0,10,0" Margin="0,0,10,0"
@ -148,6 +148,9 @@
<Style Selector="^:pointerover /template/ Button#ClearButton"> <Style Selector="^:pointerover /template/ Button#ClearButton">
<Setter Property="IsVisible" Value="{Binding $parent[ComboBox].SelectionBoxItem, Converter={x:Static ObjectConverters.IsNotNull}}" /> <Setter Property="IsVisible" Value="{Binding $parent[ComboBox].SelectionBoxItem, Converter={x:Static ObjectConverters.IsNotNull}}" />
</Style> </Style>
<Style Selector="^:pointerover /template/ PathIcon#DropDownGlyph">
<Setter Property="IsVisible" Value="{Binding $parent[ComboBox].SelectionBoxItem, Converter={x:Static ObjectConverters.IsNull}}"/>
</Style>
</Style> </Style>
<Style Selector="^.Large"> <Style Selector="^.Large">