feat: Expander.

This commit is contained in:
Zhang Dian 2024-09-29 13:32:13 +08:00
parent 3e5fa9d5bf
commit 56c30dcb8b
3 changed files with 15 additions and 17 deletions

View File

@ -9,7 +9,7 @@
</StackPanel> </StackPanel>
</Design.PreviewWith> </Design.PreviewWith>
<ControlTheme x:Key="ExpanderHeaderToggleButtonTheme" TargetType="ToggleButton"> <ControlTheme x:Key="ExpanderHeaderToggleButtonTheme" TargetType="ToggleButton">
<Setter Property="ToggleButton.Template"> <Setter Property="Template">
<ControlTemplate TargetType="ToggleButton"> <ControlTemplate TargetType="ToggleButton">
<ContentPresenter <ContentPresenter
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
@ -19,13 +19,13 @@
</Setter> </Setter>
</ControlTheme> </ControlTheme>
<ControlTheme x:Key="{x:Type Expander}" TargetType="Expander"> <ControlTheme x:Key="{x:Type Expander}" TargetType="Expander">
<Setter Property="Expander.BorderThickness" Value="1" /> <Setter Property="BorderThickness" Value="1" />
<Setter Property="Expander.BorderBrush" Value="{DynamicResource ExpanderSeparatorBorderBrush}" /> <Setter Property="BorderBrush" Value="{DynamicResource ExpanderSeparatorBorderBrush}" />
<Setter Property="Expander.CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
<Setter Property="Expander.HorizontalAlignment" Value="Stretch" /> <Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Expander.HorizontalContentAlignment" Value="Stretch" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Expander.VerticalContentAlignment" Value="Stretch" /> <Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Expander.Template"> <Setter Property="Template">
<ControlTemplate TargetType="Expander"> <ControlTemplate TargetType="Expander">
<DockPanel> <DockPanel>
<LayoutTransformControl x:Name="ExpanderHeaderLayoutContainer" Margin="{DynamicResource ExpanderHeaderMargin}"> <LayoutTransformControl x:Name="ExpanderHeaderLayoutContainer" Margin="{DynamicResource ExpanderHeaderMargin}">
@ -37,8 +37,7 @@
Background="{DynamicResource ExpanderHeaderDefaultBackground}" Background="{DynamicResource ExpanderHeaderDefaultBackground}"
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
IsChecked="{TemplateBinding IsExpanded, IsChecked="{TemplateBinding IsExpanded, Mode=TwoWay}"
Mode=TwoWay}"
IsEnabled="{TemplateBinding IsEnabled}" IsEnabled="{TemplateBinding IsEnabled}"
TextElement.FontWeight="{DynamicResource ExpanderHeaderFontWeight}" TextElement.FontWeight="{DynamicResource ExpanderHeaderFontWeight}"
TextElement.Foreground="{DynamicResource ExpanderHeaderForeground}" TextElement.Foreground="{DynamicResource ExpanderHeaderForeground}"
@ -77,8 +76,7 @@
Content="{TemplateBinding Content}" Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplate="{TemplateBinding ContentTemplate}"
Foreground="{DynamicResource ExpanderContentForeground}" Foreground="{DynamicResource ExpanderContentForeground}"
IsVisible="{TemplateBinding IsExpanded, IsVisible="{TemplateBinding IsExpanded, Mode=TwoWay}" />
Mode=TwoWay}" />
</Border> </Border>
</LayoutTransformControl> </LayoutTransformControl>
</DockPanel> </DockPanel>

View File

@ -6,8 +6,8 @@
<Setter Property="Focusable" Value="True" /> <Setter Property="Focusable" Value="True" />
<Setter Property="MinWidth" Value="6" /> <Setter Property="MinWidth" Value="6" />
<Setter Property="MinHeight" Value="6" /> <Setter Property="MinHeight" Value="6" />
<Setter Property="GridSplitter.ClipToBounds" Value="False" /> <Setter Property="ClipToBounds" Value="False" />
<Setter Property="GridSplitter.Padding" Value="2" /> <Setter Property="Padding" Value="2" />
<Setter Property="Background" Value="{DynamicResource GridSplitterBackground}" /> <Setter Property="Background" Value="{DynamicResource GridSplitterBackground}" />
<Setter Property="PreviewContent"> <Setter Property="PreviewContent">
<Template> <Template>

View File

@ -219,11 +219,11 @@
<SolidColorBrush x:Key="DateTimePickerButtonDisabledIconForeground" Color="{StaticResource GrayTextColor}" /> <SolidColorBrush x:Key="DateTimePickerButtonDisabledIconForeground" Color="{StaticResource GrayTextColor}" />
<!-- Expander --> <!-- Expander -->
<SolidColorBrush x:Key="ExpanderSeparatorBorderBrush" Color="{StaticResource WindowTextColor}" /> <SolidColorBrush x:Key="ExpanderSeparatorBorderBrush" Color="{StaticResource ButtonTextColor}" />
<SolidColorBrush x:Key="ExpanderHeaderForeground" Color="{StaticResource WindowTextColor}" /> <SolidColorBrush x:Key="ExpanderHeaderForeground" Color="{StaticResource ButtonTextColor}" />
<SolidColorBrush x:Key="ExpanderHeaderDisabledForeground" Color="{StaticResource GrayTextColor}" /> <SolidColorBrush x:Key="ExpanderHeaderDisabledForeground" Color="{StaticResource GrayTextColor}" />
<SolidColorBrush x:Key="ExpanderHeaderDefaultBackground" Color="{StaticResource WindowColor}" /> <SolidColorBrush x:Key="ExpanderHeaderDefaultBackground" Color="{StaticResource WindowColor}" />
<SolidColorBrush x:Key="ExpanderHeaderHoverBackground" Color="{StaticResource WindowColor}" /> <SolidColorBrush x:Key="ExpanderHeaderHoverBackground" Color="{StaticResource HighlightTextColor}" />
<SolidColorBrush x:Key="ExpanderHeaderPressedBackground" Color="{StaticResource WindowColor}" /> <SolidColorBrush x:Key="ExpanderHeaderPressedBackground" Color="{StaticResource WindowColor}" />
<SolidColorBrush x:Key="ExpanderContentForeground" Color="{StaticResource WindowTextColor}" /> <SolidColorBrush x:Key="ExpanderContentForeground" Color="{StaticResource WindowTextColor}" />