aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Controls/TouchComboBox.xaml
blob: 83163fcd83d9329f54c4e2faeb90c0d3764b8d1c (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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:components="clr-namespace:Tango.Touch.Components"
                    xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI"
                    xmlns:fa="http://schemas.fontawesome.io/icons/"
                    xmlns:local="clr-namespace:Tango.Touch.Controls">

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

        <ResourceDictionary>
            <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
            <converters:IsEqualConverter x:Key="IsEqualConverter" />
            <converters:DisplayMemberPathConverter x:Key="DisplayMemberPathConverter" />
        </ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>

    <Style TargetType="{x:Type local:TouchComboBox}">
        <Setter Property="Focusable" Value="True"></Setter>
        <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"></Setter>
        <Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
        <Setter Property="Padding" Value="10"></Setter>
        <Setter Property="MinPopupHeight" Value="400"></Setter>
        <Setter Property="MinPopupWidth" Value="500"></Setter>
        <Setter Property="Title" Value="Select a value"></Setter>
        <Setter Property="VerticalContentAlignment" Value="Bottom"></Setter>
        <Setter Property="MinHeight" Value="40"></Setter>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Border>
                        <DockPanel>
                            <Label VerticalAlignment="Center" Padding="30" FontSize="{StaticResource TangoComboBoxItemFontSize}" Foreground="{StaticResource TangoDarkForegroundBrush}">
                                <Label.Style>
                                    <Style TargetType="Label">
                                        <Setter Property="Background" Value="Transparent"></Setter>
                                        <Style.Triggers>
                                            <DataTrigger Value="True">
                                                <DataTrigger.Binding>
                                                    <MultiBinding Converter="{StaticResource IsEqualConverter}">
                                                        <Binding Path="." />
                                                        <Binding RelativeSource="{RelativeSource AncestorType=local:TouchListBox}" Path="DataContext.SelectedItem" />
                                                    </MultiBinding>
                                                </DataTrigger.Binding>
                                                <Setter Property="Background" Value="{StaticResource TangoMidBackgroundBrush}"></Setter>
                                                <Setter Property="Foreground" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Label.Style>
                                <Label.Content>
                                    <MultiBinding Converter="{StaticResource DisplayMemberPathConverter}">
                                        <Binding Path="." />
                                        <Binding RelativeSource="{RelativeSource AncestorType=local:TouchListBox}" Path="DataContext.DisplayMemberPath" />
                                    </MultiBinding>
                                </Label.Content>
                            </Label>
                        </DockPanel>
                    </Border>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="SelectedItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Label VerticalAlignment="Center" Padding="5 5 5 2" Foreground="{StaticResource TangoDarkForegroundBrush}">
                        <Label.Content>
                            <MultiBinding Converter="{StaticResource DisplayMemberPathConverter}">
                                <Binding Path="." />
                                <Binding RelativeSource="{RelativeSource AncestorType=local:TouchComboBox}" Path="DisplayMemberPath" />
                            </MultiBinding>
                        </Label.Content>
                    </Label>
                </DataTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:TouchComboBox}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">

                        <DockPanel Background="Transparent">
                            <Border DockPanel.Dock="Bottom" Visibility="{Binding RelativeSource={RelativeSource AncestorType=local:TouchComboBox},Path=(Validation.HasError),Converter={StaticResource BooleanToVisibilityConverter}}">
                                <TextBlock FontSize="12" Foreground="{StaticResource TangoValidationErrorBrush}" Margin="0 5 0 0" TextWrapping="Wrap" Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchComboBox},Path=(Validation.Errors).CurrentItem.ErrorContent}"></TextBlock>
                            </Border>

                            <DockPanel>
                                <Grid DockPanel.Dock="Bottom" Height="2">
                                    <Rectangle Height="1" Fill="{StaticResource TangoTextWatermarkBrush}" />
                                    <Rectangle Height="2" RenderTransformOrigin="0.5,0.5" >
                                        <Rectangle.Style>
                                            <Style TargetType="Rectangle">
                                                <Setter Property="Fill" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter>
                                                <Setter Property="RenderTransform">
                                                    <Setter.Value>
                                                        <ScaleTransform ScaleY="1" ScaleX="0" />
                                                    </Setter.Value>
                                                </Setter>
                                                <Style.Triggers>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchComboBox},Path=IsFocused}" Value="True">
                                                        <DataTrigger.EnterActions>
                                                            <BeginStoryboard>
                                                                <Storyboard>
                                                                    <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="00:00:0.4" />
                                                                </Storyboard>
                                                            </BeginStoryboard>
                                                        </DataTrigger.EnterActions>
                                                        <DataTrigger.ExitActions>
                                                            <BeginStoryboard>
                                                                <Storyboard>
                                                                    <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="0" Duration="00:00:0.4" />
                                                                </Storyboard>
                                                            </BeginStoryboard>
                                                        </DataTrigger.ExitActions>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchComboBox},Path=IsFocused}" Value="True">
                                                        <DataTrigger.EnterActions>
                                                            <BeginStoryboard>
                                                                <Storyboard>
                                                                    <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="1" Duration="00:00:0.4" />
                                                                </Storyboard>
                                                            </BeginStoryboard>
                                                        </DataTrigger.EnterActions>
                                                        <DataTrigger.ExitActions>
                                                            <BeginStoryboard>
                                                                <Storyboard>
                                                                    <DoubleAnimation Storyboard.TargetProperty="RenderTransform.ScaleX" To="0" Duration="00:00:0.4" />
                                                                </Storyboard>
                                                            </BeginStoryboard>
                                                        </DataTrigger.ExitActions>
                                                    </DataTrigger>
                                                    <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchComboBox},Path=(Validation.HasError)}" Value="True">
                                                        <Setter Property="Fill" Value="{StaticResource TangoValidationErrorBrush}"></Setter>
                                                        <Setter Property="RenderTransform">
                                                            <Setter.Value>
                                                                <ScaleTransform ScaleY="1" ScaleX="1" />
                                                            </Setter.Value>
                                                        </Setter>
                                                    </DataTrigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Rectangle.Style>
                                    </Rectangle>
                                </Grid>

                                <Grid>
                                    <components:Ripple RippleBrush="{StaticResource TangoRippleDarkBrush}" RippleFactor="15">
                                        <DockPanel>
                                            <local:TouchIcon IsHitTestVisible="False" VerticalAlignment="Center" DockPanel.Dock="Right" Icon="ChevronDown" Width="12">
                                                <local:TouchIcon.Style>
                                                    <Style TargetType="local:TouchIcon">
                                                        <Setter Property="Foreground" Value="{StaticResource TangoTextWatermarkBrush}"></Setter>
                                                        <Style.Triggers>
                                                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchComboBox},Path=IsFocused}" Value="True">
                                                                <Setter Property="Foreground" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter>
                                                            </DataTrigger>
                                                        </Style.Triggers>
                                                    </Style>
                                                </local:TouchIcon.Style>
                                            </local:TouchIcon>

                                            <Grid>
                                                <ContentControl VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Padding="0 0 0 2" FocusVisualStyle="{x:Null}" Content="{Binding RelativeSource={RelativeSource AncestorType=local:TouchComboBox},Path=SelectedItem}" ContentTemplate="{TemplateBinding SelectedItemTemplate}" Background="Transparent"></ContentControl>
                                                <TextBlock VerticalAlignment="{TemplateBinding VerticalContentAlignment}" IsHitTestVisible="False" Text="{TemplateBinding Watermark}" Foreground="{StaticResource TangoTextWatermarkBrush}">
                                                    <TextBlock.Style>
                                                        <Style TargetType="TextBlock">
                                                            <Setter Property="Visibility" Value="Hidden"></Setter>
                                                            <Style.Triggers>
                                                                <MultiDataTrigger>
                                                                    <MultiDataTrigger.Conditions>
                                                                        <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchComboBox},Path=SelectedItem}" Value="{x:Null}"></Condition>
                                                                        <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchComboBox},Path=IsFocused}" Value="False"></Condition>
                                                                    </MultiDataTrigger.Conditions>
                                                                    <Setter Property="Visibility" Value="Visible"></Setter>
                                                                </MultiDataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </TextBlock.Style>
                                                </TextBlock>
                                            </Grid>
                                        </DockPanel>
                                    </components:Ripple>
                                </Grid>
                            </DockPanel>
                        </DockPanel>

                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>