Blame view

sources/RoboforkApp/Resources/Expander.xaml 8.12 KB
729be9a6d   doan   New Project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
  <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  
      <ResourceDictionary.MergedDictionaries>
          <ResourceDictionary Source="Brushes.xaml" />
      </ResourceDictionary.MergedDictionaries>
  
      <Style x:Key="ToggleButtonStyle"
             TargetType="ToggleButton">
          <Setter Property="SnapsToDevicePixels"
                  Value="true" />
          <Setter Property="OverridesDefaultStyle"
                  Value="true" />
          <Setter Property="Template">
              <Setter.Value>
                  <ControlTemplate TargetType="ToggleButton">
                      <Border x:Name="Border"
                              CornerRadius="2"
                              BorderThickness="1"
                              Background="{StaticResource NormalBrush}"
                              BorderBrush="{StaticResource NormalBorderBrush}">
                          <ContentPresenter Margin="{TemplateBinding Padding}"
                                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                      </Border>
                      <ControlTemplate.Triggers>
                          <Trigger Property="IsMouseOver"
                                   Value="true">
                              <Setter TargetName="Border"
                                      Property="Background"
                                      Value="{StaticResource DarkBrush}" />
                          </Trigger>
                          <Trigger Property="IsPressed"
                                   Value="true">
                              <Setter TargetName="Border"
                                      Property="Background"
                                      Value="{StaticResource PressedBrush}" />
                              <Setter TargetName="Border"
                                      Property="BorderBrush"
                                      Value="{StaticResource PressedBorderBrush}" />
                          </Trigger>
                      </ControlTemplate.Triggers>
                  </ControlTemplate>
              </Setter.Value>
          </Setter>
      </Style>
  
      <Style TargetType="Expander">
          <Setter Property="Padding"
                  Value="8" />
          <Setter Property="Template">
              <Setter.Value>
                  <ControlTemplate TargetType="Expander">
                      <DockPanel>
                          <ToggleButton Style="{StaticResource ToggleButtonStyle}"
                                        DockPanel.Dock="Top"
                                        IsChecked="{Binding Path=IsExpanded,Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                        HorizontalContentAlignment="Left"
                                        VerticalContentAlignment="Center">
                              <ToggleButton.Content>
                                  <StackPanel Orientation="Horizontal">
                                      <Path SnapsToDevicePixels="True"
                                            Name="Arrow"
                                            Margin="8,0,8,0"
                                            Fill="{TemplateBinding Foreground}"
                                            Stroke="{TemplateBinding Foreground}"
                                            StrokeThickness="0.5"
                                            RenderTransformOrigin="0.5,0.5"
                                            HorizontalAlignment="Right"
                                            VerticalAlignment="Center"
                                            Data="M 0 0 L 0 8 L 5 4 Z">
                                          <Path.RenderTransform>
                                              <RotateTransform Angle="0" />
                                          </Path.RenderTransform>
                                      </Path>
                                      <ContentPresenter Name="HeaderContent"
                                                        Margin="4"
                                                        ContentSource="Header" />
                                  </StackPanel>
                              </ToggleButton.Content>
                          </ToggleButton>
                          <Border Name="Content"
                                  BorderThickness="1,0,1,1"
                                  BorderBrush="{StaticResource NormalBorderBrush}"
                                  Background="{TemplateBinding Background}"
                                  CornerRadius="0,0,1,1"
                                  SnapsToDevicePixels="True">
                              <Border.LayoutTransform>
                                  <ScaleTransform ScaleY="0" />
                              </Border.LayoutTransform>
                              <ContentPresenter Content="{TemplateBinding Content}"
                                                ToolTipService.IsEnabled="False" />
                          </Border>
                      </DockPanel>
                      <ControlTemplate.Triggers>
                          <Trigger Property="Expander.IsExpanded"
                                   Value="True">
                              <Trigger.EnterActions>
                                  <BeginStoryboard>
                                      <Storyboard>
                                          <DoubleAnimation Storyboard.TargetName="Content"
                                                           Storyboard.TargetProperty="LayoutTransform.ScaleY"
                                                           To="1"
                                                           Duration="0:0:0.5" />
                                          <DoubleAnimation Storyboard.TargetName="Content"
                                                           Storyboard.TargetProperty="Opacity"
                                                           To="1"
                                                           Duration="0:0:0.5" />
                                          <DoubleAnimation Storyboard.TargetName="Arrow"
                                                           Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)"
                                                           Duration="0:0:0.2"
                                                           To="90"
                                                           DecelerationRatio="1" />
                                      </Storyboard>
                                  </BeginStoryboard>
                              </Trigger.EnterActions>
                              <Trigger.ExitActions>
                                  <BeginStoryboard>
                                      <Storyboard>
                                          <DoubleAnimation Storyboard.TargetName="Content"
                                                           Storyboard.TargetProperty="LayoutTransform.ScaleY"
                                                           To="0"
                                                           Duration="0:0:0.5" />
                                          <DoubleAnimation Storyboard.TargetName="Content"
                                                           Storyboard.TargetProperty="Opacity"
                                                           To="0"
                                                           Duration="0:0:0.5" />
                                          <DoubleAnimation Storyboard.TargetName="Arrow"
                                                           Storyboard.TargetProperty="(FrameworkElement.RenderTransform).(RotateTransform.Angle)"
                                                           Duration="0:0:0.2"
                                                           AccelerationRatio="1" />
                                      </Storyboard>
                                  </BeginStoryboard>
                              </Trigger.ExitActions>
                          </Trigger>
                      </ControlTemplate.Triggers>
                  </ControlTemplate>
              </Setter.Value>
          </Setter>
      </Style>
  </ResourceDictionary>