Files
ShrlAlgoToolkit/WPFDark/StandardControls/Expander.xaml
ShrlAlgo 4d35cadb56 更新
2025-07-11 09:20:23 +08:00

159 lines
8.8 KiB
XML

<ResourceDictionary x:Class="WPFDark.StandardControls.ExpanderEventHandler"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:internal="clr-namespace:WPFDark.StandardControls.Internal"
xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:wpf="clr-namespace:WPFDark">
<Style x:Key="ExpanderDownHeaderStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<StackPanel x:Name="Background"
Background="Transparent"
Orientation="Horizontal"
SnapsToDevicePixels="False">
<Path x:Name="arrow"
Width="10"
Height="10"
Margin="10,2,8,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 0 0 L 6.9 4 L 0 8 Z"
Fill="#A0A0A0"
SnapsToDevicePixels="False" />
<ContentPresenter Margin="2,0,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Center"
RecognizesAccessKey="True"
SnapsToDevicePixels="True" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="arrow" Property="Data" Value="M 0 0 L 8 0 L 4 6.9 Z" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="arrow" Property="Fill" Value="#B0B0B0" />
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="arrow" Property="Fill" Value="#C0C0C0" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="arrow" Property="Fill" Value="{DynamicResource InactiveBackgroundBrushKey}" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="Background" Property="Background" Value="#14FFFFFF" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter TargetName="Background" Property="Background" Value="#0CFFFFFF" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<internal:ExpanderMultiplyConverter x:Key="Multiply" />
<Style x:Key="DefaultExpanderStyle" TargetType="{x:Type Expander}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Top" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Expander}">
<StackPanel x:Name="Frame"
Loaded="Frame_OnLoaded"
PreviewMouseWheel="OnPreviewMouseWheel">
<StackPanel.Tag>
<system:Double>1.0</system:Double>
</StackPanel.Tag>
<StackPanel.Height>
<MultiBinding Converter="{StaticResource Multiply}">
<Binding ElementName="HeaderSite" Path="ActualHeight" />
<Binding ElementName="ExpandSite" Path="ActualHeight" />
<Binding Path="Tag" RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</StackPanel.Height>
<ToggleButton x:Name="HeaderSite"
MinWidth="0.0"
MinHeight="0.0"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}"
ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}"
FontFamily="{TemplateBinding FontFamily}"
FontSize="{TemplateBinding FontSize}"
FontStretch="{TemplateBinding FontStretch}"
FontStyle="{TemplateBinding FontStyle}"
FontWeight="{TemplateBinding FontWeight}"
Foreground="{TemplateBinding Foreground}"
IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource ExpanderDownHeaderStyle}" />
<ContentPresenter x:Name="ExpandSite"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Focusable="False" />
</StackPanel>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
</Trigger>
<Trigger Property="IsExpanded" Value="True">
<Trigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="Frame"
Storyboard.TargetProperty="Tag"
To="1.0"
Duration="0:0:0.3">
<DoubleAnimation.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetName="Frame"
Storyboard.TargetProperty="Tag"
To="0.0"
Duration="0:0:0.3">
<DoubleAnimation.EasingFunction>
<CubicEase EasingMode="EaseOut" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</BeginStoryboard>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style BasedOn="{StaticResource DefaultExpanderStyle}" TargetType="{x:Type Expander}" />
</ResourceDictionary>