aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Controls/TouchExpander.xaml
blob: 68ba4382ace4d83796b5b54cd026f01b7269ae97 (plain)
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
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:fa="http://schemas.fontawesome.io/icons/"
                    xmlns:local="clr-namespace:Tango.Touch.Controls">


    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="../Resources/Colors.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type local:TouchExpander}">
        <Setter Property="Padding" Value="10"></Setter>
        <Setter Property="Background" Value="{StaticResource TangoPrimaryBackgroundBrush}"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TouchExpander}">
                    <local:TouchDropShadowBorder Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" CornerRadius="{TemplateBinding CornerRadius}">

                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>

                            <DockPanel Grid.Row="0">
                                <local:TouchToggleButton CornerRadius="50" RenderTransformOrigin="0.5,0.5" Background="{StaticResource TangoExpanderIconBackgroundBrush}" EnableDropShadow="False" Width="40" Height="40" DockPanel.Dock="Right" IsChecked="{Binding RelativeSource={RelativeSource AncestorType=local:TouchExpander},Path=IsExpanded,Mode=TwoWay}">
                                    <local:TouchToggleButton.RenderTransform>
                                        <RotateTransform x:Name="Rotate" />
                                    </local:TouchToggleButton.RenderTransform>
                                    <local:TouchToggleButton.Triggers>
                                        <EventTrigger RoutedEvent="ToggleButton.Checked">
                                            <EventTrigger.Actions>
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <DoubleAnimation Storyboard.TargetName="Rotate" Storyboard.TargetProperty="Angle" Duration="00:00:0.2" To="360" />
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </EventTrigger.Actions>
                                        </EventTrigger>
                                        <EventTrigger RoutedEvent="ToggleButton.Unchecked">
                                            <EventTrigger.Actions>
                                                <BeginStoryboard>
                                                    <Storyboard>
                                                        <DoubleAnimation Storyboard.TargetName="Rotate" Storyboard.TargetProperty="Angle" Duration="00:00:0.2" To="0" />
                                                    </Storyboard>
                                                </BeginStoryboard>
                                            </EventTrigger.Actions>
                                        </EventTrigger>
                                    </local:TouchToggleButton.Triggers>
                                    <local:TouchToggleButton.CheckedContent>
                                        <Grid>
                                            <local:TouchIcon Icon="Minus" Foreground="{StaticResource TangoExpanderIconForegroundBrush}" Width="10" Height="10" />
                                        </Grid>
                                    </local:TouchToggleButton.CheckedContent>
                                    <Grid>
                                        <local:TouchIcon Icon="Plus" Foreground="{StaticResource TangoExpanderIconForegroundBrush}" Width="10" Height="10" />
                                    </Grid>
                                </local:TouchToggleButton>

                                <ToggleButton IsChecked="{Binding RelativeSource={RelativeSource AncestorType=local:TouchExpander},Path=IsExpanded,Mode=TwoWay}">
                                    <ToggleButton.Template>
                                        <ControlTemplate TargetType="ToggleButton">
                                            <ContentPresenter/>
                                        </ControlTemplate>
                                    </ToggleButton.Template>
                                    <Border Background="Transparent">
                                        <ContentPresenter Content="{TemplateBinding Header}" />
                                    </Border>
                                </ToggleButton>
                            </DockPanel>

                            <Grid Grid.Row="1">
                                <Grid.Style>
                                    <Style TargetType="Grid">
                                        <Setter Property="LayoutTransform">
                                            <Setter.Value>
                                                <ScaleTransform x:Name="scaleTransform" ScaleX="1" ScaleY="0" />
                                            </Setter.Value>
                                        </Setter>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchExpander},Path=IsExpanded}" Value="True">
                                                <DataTrigger.EnterActions>
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetProperty="(Grid.LayoutTransform).(ScaleTransform.ScaleY)" Duration="00:00:0.2" To="1" />
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </DataTrigger.EnterActions>
                                                <DataTrigger.ExitActions>
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <DoubleAnimation Storyboard.TargetProperty="(Grid.LayoutTransform).(ScaleTransform.ScaleY)" Duration="00:00:0.2" To="0" />
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </DataTrigger.ExitActions>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Grid.Style>
                                <ContentPresenter Content="{TemplateBinding Content}" />
                            </Grid>
                        </Grid>
                    </local:TouchDropShadowBorder>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>