跳到主要内容

github/tai

公开

Tai · Windows 软件与网站使用时长统计。上游 Planshit/Tai 的源码镜像,非灵栈原创;MIT 许可。来源:https://github.com/Planshit/Tai 。本次为手动同步,暂不提供安装包。

浏览文件

Expander.xaml

119 行 · 7.3 KB历史下载
1<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3 xmlns:local="clr-namespace:UI.Controls.Expander"
4 xmlns:btn="clr-namespace:UI.Controls.Button"
5 xmlns:base="clr-namespace:UI.Controls.Base">
6
7
8 <Style TargetType="{x:Type local:Expander}">
9 <Setter Property="Background" Value="{DynamicResource ExpanderBgBrush}"/>
10 <Setter Property="BorderBrush" Value="{DynamicResource SettingPanelBorderBrush}"/>
11 <Setter Property="BorderThickness" Value="1"/>
12 <Setter Property="CornerRadius" Value="6"/>
13 <Setter Property="Padding" Value="15"/>
14 <Setter Property="Template">
15 <Setter.Value>
16 <ControlTemplate TargetType="{x:Type local:Expander}">
17 <Border ClipToBounds="True" Background="Transparent">
18 <Grid Background="Transparent">
19 <Grid.RowDefinitions>
20 <RowDefinition Height="Auto" />
21 <RowDefinition x:Name="ContentRow"
22 Height="{Binding Height,ElementName=ContentHeight}" />
23 </Grid.RowDefinitions>
24 <VisualStateManager.VisualStateGroups>
25 <VisualStateGroup x:Name="CommonStates">
26 <VisualState x:Name="Normal" />
27 <VisualState x:Name="MouseOver" />
28 <!--<VisualState x:Name="Disabled">
29 <Storyboard>
30 <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
31 Storyboard.TargetProperty="(Panel.Background).
32 (GradientBrush.GradientStops)[1].(GradientStop.Color)">
33 <EasingColorKeyFrame KeyTime="0"
34 Value="{StaticResource DisabledControlDarkColor}" />
35 </ColorAnimationUsingKeyFrames>
36 <ColorAnimationUsingKeyFrames Storyboard.TargetName="Border"
37 Storyboard.TargetProperty="(Border.BorderBrush).
38 (GradientBrush.GradientStops)[1].(GradientStop.Color)">
39 <EasingColorKeyFrame KeyTime="0"
40 Value="{StaticResource DisabledBorderLightColor}" />
41 </ColorAnimationUsingKeyFrames>
42 </Storyboard>
43 </VisualState>-->
44 </VisualStateGroup>
45 </VisualStateManager.VisualStateGroups>
46 <Canvas x:Name="ContentHeight" Visibility="Collapsed" Height="0"/>
47
48 <Border x:Name="HeaderBorder"
49 Grid.Row="0"
50 Padding="{TemplateBinding Padding}"
51 Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" Panel.ZIndex="2">
52
53 <Grid>
54 <Grid.ColumnDefinitions>
55 <ColumnDefinition Width="*" />
56 <ColumnDefinition Width="40" />
57
58 </Grid.ColumnDefinitions>
59
60 <ContentPresenter
61 Margin="4"
62 ContentSource="Header"
63 RecognizesAccessKey="True" TextElement.FontSize="14" VerticalAlignment="Center"/>
64 <btn:IconButton x:Name="ExpBtn" Grid.Column="1" Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:Expander}}, Path=ExpanderCommand}">
65 <base:Icon x:Name="Icon" IconType="ChevronDownMed" FontSize="12" RenderTransformOrigin=".5,.5">
66 <base:Icon.RenderTransform>
67 <RotateTransform Angle="0"/>
68 </base:Icon.RenderTransform>
69 </base:Icon>
70 </btn:IconButton>
71 </Grid>
72 </Border>
73 <Border x:Name="Content"
74 Grid.Row="1"
75 BorderThickness="1,0,1,1"
76 BorderBrush="{TemplateBinding BorderBrush}"
77 Background="{DynamicResource ExpanderContentBgBrush}"
78 CornerRadius="0,0,6,6">
79 <Border.RenderTransform>
80 <TranslateTransform X="0" Y="0"/>
81 </Border.RenderTransform>
82 <StackPanel x:Name="ContentStackPanel">
83 <ContentPresenter />
84 </StackPanel>
85 </Border>
86 </Grid>
87 </Border>
88 <ControlTemplate.Triggers>
89 <Trigger Property="IsExpanded"
90 Value="True">
91 <Setter Property="CornerRadius" Value="6,6,0,0"/>
92 <!--<Setter TargetName="ContentRow"
93 Property="Height"
94 Value="{Binding Height, ElementName=Content}" />-->
95 </Trigger>
96 <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsExpanded}" Value="True">
97 <DataTrigger.EnterActions>
98 <BeginStoryboard>
99 <Storyboard>
100 <DoubleAnimation Storyboard.TargetProperty="(base:Icon.RenderTransform).(RotateTransform.Angle)"
101 Storyboard.TargetName="Icon" Duration="00:00:0.2" To="180"/>
102 </Storyboard>
103 </BeginStoryboard>
104 </DataTrigger.EnterActions>
105 <DataTrigger.ExitActions>
106 <BeginStoryboard>
107 <Storyboard>
108 <DoubleAnimation Storyboard.TargetProperty="(base:Icon.RenderTransform).(RotateTransform.Angle)"
109 Storyboard.TargetName="Icon" Duration="00:00:0.2" To="0"/>
110 </Storyboard>
111 </BeginStoryboard>
112 </DataTrigger.ExitActions>
113 </DataTrigger>
114 </ControlTemplate.Triggers>
115 </ControlTemplate>
116 </Setter.Value>
117 </Setter>
118 </Style>
119</ResourceDictionary>