summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.UAP/AutoSuggestStyle.xaml
blob: 3c85a01f590dd88185aec8899d4f0e477c773c97 (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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:uwp="using:Xamarin.Forms.Platform.UWP">

	<!-- Default Style for AutoSuggestBox -->
	<Style TargetType="AutoSuggestBox">
		<Setter Property="VerticalAlignment" Value="Top" />
		<Setter Property="IsTabStop" Value="False" />
		<Setter Property="TextBoxStyle" Value="{StaticResource AutoSuggestBoxTextBoxStyle}" />
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="AutoSuggestBox">
					<Grid>
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="Orientation">
								<VisualState x:Name="Landscape"/>
								<VisualState x:Name="Portrait"/>
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>
						<uwp:FormsTextBox x:Name="TextBox"
                      Style="{TemplateBinding TextBoxStyle}"
                      FontFamily="{TemplateBinding FontFamily}"
                      FontSize="{TemplateBinding FontSize}"
                      FontStyle="{TemplateBinding FontStyle}"
                      PlaceholderText="{TemplateBinding PlaceholderText}"
                      Header="{TemplateBinding Header}"
                      Width="{TemplateBinding Width}"
                      ScrollViewer.BringIntoViewOnFocusChange="False"
                      Canvas.ZIndex="0"
                      Margin="0"
                      DesiredCandidateWindowAlignment="BottomEdge"/>
						<Popup x:Name="SuggestionsPopup">
							<Border x:Name="SuggestionsContainer">
								<Border.RenderTransform>
									<TranslateTransform x:Name="UpwardTransform"/>
								</Border.RenderTransform>
								<ListView x:Name="SuggestionsList"
                          Background="{ThemeResource SystemControlBackgroundChromeMediumLowBrush}"
                          BorderThickness="{ThemeResource AutoSuggestListBorderThemeThickness}"
                          BorderBrush="{ThemeResource SystemControlForegroundBaseMediumLowBrush}"
                          DisplayMemberPath="{TemplateBinding DisplayMemberPath}"
                          IsItemClickEnabled="True"
                          ItemTemplate="{TemplateBinding ItemTemplate}"
                          ItemTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                          ItemContainerStyle="{TemplateBinding ItemContainerStyle}"
                          MaxHeight="{ThemeResource AutoSuggestListMaxHeight}"
                          Margin="{ThemeResource AutoSuggestListMargin}">
									<ListView.ItemContainerTransitions>
										<TransitionCollection />
									</ListView.ItemContainerTransitions>
								</ListView>
							</Border>
						</Popup>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style TargetType="uwp:FormsTextBox" x:Key="AutoSuggestBoxTextBoxStyle">
		<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
		<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
		<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
		<Setter Property="ForegroundFocusBrush" Value="{ThemeResource SystemControlForegroundChromeBlackHighBrush}" />
		<Setter Property="PlaceholderForegroundBrush" Value="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
		<Setter Property="PlaceholderForegroundFocusBrush" Value="{ThemeResource SystemControlPageTextChromeBlackMediumLowBrush}" />
		<Setter Property="Background" Value="{ThemeResource SystemControlBackgroundAltHighBrush}" />
		<Setter Property="BackgroundFocusBrush" Value="{ThemeResource SystemControlBackgroundChromeWhiteBrush}" />
		<Setter Property="BorderBrush" Value="{ThemeResource SystemControlForegroundChromeDisabledLowBrush}" />
		<Setter Property="SelectionHighlightColor" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
		<Setter Property="BorderThickness" Value="{ThemeResource TextControlBorderThemeThickness}" />
		<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}" />
		<Setter Property="FontSize" Value="{ThemeResource ControlContentThemeFontSize}" />
		<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
		<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
		<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
		<Setter Property="Padding" Value="{ThemeResource TextControlThemePadding}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="uwp:FormsTextBox">
					<Grid>
						<Grid.Resources>
							<Style x:Name="DeleteButtonStyle" TargetType="Button">
								<Setter Property="Template">
									<Setter.Value>
										<ControlTemplate TargetType="Button">
											<Grid>
												<VisualStateManager.VisualStateGroups>
													<VisualStateGroup x:Name="CommonStates">
														<VisualState x:Name="Normal" />
														<VisualState x:Name="PointerOver">
															<Storyboard>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                             Storyboard.TargetProperty="Background">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightTransparentBrush}" />
																</ObjectAnimationUsingKeyFrames>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
                                                             Storyboard.TargetProperty="Foreground">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource FormsCancelBackgroundBrush}" />
																</ObjectAnimationUsingKeyFrames>
															</Storyboard>
														</VisualState>
														<VisualState x:Name="Pressed">
															<Storyboard>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                             Storyboard.TargetProperty="Background">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
																</ObjectAnimationUsingKeyFrames>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetName="GlyphElement"
                                                             Storyboard.TargetProperty="Foreground">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltChromeWhiteBrush}" />
																</ObjectAnimationUsingKeyFrames>
															</Storyboard>
														</VisualState>
														<VisualState x:Name="Disabled">
															<Storyboard>
																<DoubleAnimation Storyboard.TargetName="BorderElement"
                                               Storyboard.TargetProperty="Opacity"
                                               To="0"
                                               Duration="0" />
															</Storyboard>
														</VisualState>
													</VisualStateGroup>
												</VisualStateManager.VisualStateGroups>
												<Border x:Name="BorderElement"
                              BorderBrush="{ThemeResource TextBoxButtonBorderThemeBrush}"
                              BorderThickness="{TemplateBinding BorderThickness}"
                              Background="{ThemeResource FormsCancelBackgroundBrush}">
													<TextBlock x:Name="GlyphElement"
                                   Foreground="{ThemeResource FormsCancelForegroundBrush}"
                                   VerticalAlignment="Center"
                                   HorizontalAlignment="Center"
                                   FontStyle="Normal"
                                   FontSize="12"
                                   Text="&#xE10A;"
                                   FontFamily="{ThemeResource SymbolThemeFontFamily}"
                                   AutomationProperties.AccessibilityView="Raw"/>
												</Border>
											</Grid>
										</ControlTemplate>
									</Setter.Value>
								</Setter>
							</Style>
							<Style x:Name="QueryButtonStyle" TargetType="Button">
								<Setter Property="Template">
									<Setter.Value>
										<ControlTemplate TargetType="Button">
											<Grid>
												<VisualStateManager.VisualStateGroups>
													<VisualStateGroup x:Name="CommonStates">
														<VisualState x:Name="Normal" />
														<VisualState x:Name="PointerOver">
															<Storyboard>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                             Storyboard.TargetProperty="Background">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightTransparentBrush}" />
																</ObjectAnimationUsingKeyFrames>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                             Storyboard.TargetProperty="Foreground">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltAccentBrush}" />
																</ObjectAnimationUsingKeyFrames>
															</Storyboard>
														</VisualState>
														<VisualState x:Name="Pressed">
															<Storyboard>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                             Storyboard.TargetProperty="Background">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
																</ObjectAnimationUsingKeyFrames>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentPresenter"
                                                             Storyboard.TargetProperty="Foreground">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltChromeWhiteBrush}" />
																</ObjectAnimationUsingKeyFrames>
															</Storyboard>
														</VisualState>
														<VisualState x:Name="Disabled">
															<Storyboard>
																<DoubleAnimation Storyboard.TargetName="BorderElement"
                                               Storyboard.TargetProperty="Opacity"
                                               To="0"
                                               Duration="0" />
															</Storyboard>
														</VisualState>
													</VisualStateGroup>
												</VisualStateManager.VisualStateGroups>
												<Border x:Name="BorderElement"
                              BorderBrush="{ThemeResource TextBoxButtonBorderThemeBrush}"
                              BorderThickness="{TemplateBinding BorderThickness}"
                              Background="{ThemeResource TextBoxButtonBackgroundThemeBrush}">
													<ContentPresenter x:Name="ContentPresenter"
                                          Content="{TemplateBinding Content}"
                                          ContentTransitions="{TemplateBinding ContentTransitions}"
                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                          Margin="{TemplateBinding Padding}"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                          AutomationProperties.AccessibilityView="Raw"/>
												</Border>
											</Grid>
										</ControlTemplate>
									</Setter.Value>
								</Setter>
							</Style>
						</Grid.Resources>
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="CommonStates">
								<VisualState x:Name="Disabled">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="HeaderContentPresenter"
                                                   Storyboard.TargetProperty="Foreground">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
                                                 Storyboard.TargetProperty="Background">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledTransparentBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                 Storyboard.TargetProperty="Background">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlBackgroundBaseLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                 Storyboard.TargetProperty="BorderBrush">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement"
                                                 Storyboard.TargetProperty="Foreground">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledChromeDisabledLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter"
                                                 Storyboard.TargetProperty="Foreground">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledChromeDisabledLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Normal" />
								<VisualState x:Name="PointerOver">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                 Storyboard.TargetProperty="BorderBrush">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightChromeAltLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
                                                 Storyboard.TargetProperty="Opacity">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundHoverOpacity}" />
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Focused">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="PlaceholderTextContentPresenter"
                                                 Storyboard.TargetProperty="Foreground">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding PlaceholderForegroundFocusBrush, RelativeSource={RelativeSource TemplatedParent}}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement"
                                                 Storyboard.TargetProperty="Background">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding BackgroundFocusBrush, RelativeSource={RelativeSource TemplatedParent}}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BackgroundElement" 
                                                 Storyboard.TargetProperty="Opacity">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundFocusedOpacity}"  />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="BorderElement"
                                                 Storyboard.TargetProperty="BorderBrush">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement" 
                                                 Storyboard.TargetProperty="Foreground">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding ForegroundFocusBrush, RelativeSource={RelativeSource TemplatedParent}}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="ContentElement"
                                                 Storyboard.TargetProperty="RequestedTheme">
											<DiscreteObjectKeyFrame KeyTime="0" Value="Light" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="QueryButton"
                                                 Storyboard.TargetProperty="Foreground">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlBackgroundChromeBlackMediumBrush}" />
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
							<VisualStateGroup x:Name="ButtonStates">
								<VisualState x:Name="ButtonVisible">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetName="DeleteButton"
                                                 Storyboard.TargetProperty="Visibility">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="ButtonCollapsed" />
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="Auto" />
							<ColumnDefinition Width="Auto" />
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="*" />
						</Grid.RowDefinitions>
						<Border x:Name="BackgroundElement"
                  Grid.Row="1"
                  Background="{TemplateBinding Background}"
                  Margin="{TemplateBinding BorderThickness}"
                  Opacity="{ThemeResource TextControlBackgroundRestOpacity}"
                  Grid.ColumnSpan="3"
                  Grid.RowSpan="1"/>
						<Border x:Name="BorderElement"
                  Grid.Row="1"
                  BorderBrush="{TemplateBinding BorderBrush}"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  Grid.ColumnSpan="3"
                  Grid.RowSpan="1"/>
						<ContentPresenter x:Name="HeaderContentPresenter"
                            x:DeferLoadStrategy="Lazy"
                            Visibility="Collapsed"
                            Grid.Row="0"
                            Foreground="{Binding PlaceholderForegroundBrush, RelativeSource={RelativeSource TemplatedParent}}"
                            Margin="0,0,0,8"
                            Grid.ColumnSpan="3"
                            Content="{TemplateBinding Header}"
                            ContentTemplate="{TemplateBinding HeaderTemplate}"
                            FontWeight="Normal"
                            TextWrapping="Wrap" />
						<ScrollViewer x:Name="ContentElement"
                        Grid.Row="1"
                        HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}"
                        HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
                        VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}"
                        VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
                        IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}"
                        IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}"
                        IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
                        Margin="{TemplateBinding BorderThickness}"
                        Padding="{TemplateBinding Padding}"
                        IsTabStop="False"
                        AutomationProperties.AccessibilityView="Raw"
                        ZoomMode="Disabled" />
						<!-- Converting the TextAlignment set for the control's input text to a HorizontalAlignment 
                            so the PlaceholderText's alignment will match the input text -->
						<ContentControl x:Name="PlaceholderTextContentPresenter"
                        Grid.Row="1"
                        Foreground="{Binding PlaceholderForegroundBrush, RelativeSource={RelativeSource TemplatedParent}}"
                        Margin="{TemplateBinding BorderThickness}"
                        Padding="{TemplateBinding Padding}"
                        IsTabStop="False"
                        Grid.ColumnSpan="3"
                        Content="{TemplateBinding PlaceholderText}"
                        FontFamily="{TemplateBinding FontFamily}"
                        FontSize="{TemplateBinding FontSize}"
                        FontStyle="{TemplateBinding FontStyle}"
                        IsHitTestVisible="False"
                        HorizontalAlignment="{Binding TextAlignment, 
                                            RelativeSource={RelativeSource Mode=TemplatedParent}, 
                                            Converter={StaticResource AlignmentConverter}}" />
						<Button x:Name="DeleteButton"
                  Grid.Row="1"
                  Style="{StaticResource DeleteButtonStyle}"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  Margin="{ThemeResource HelperButtonThemePadding}"
                  IsTabStop="False"
                  Grid.Column="1"
                  Visibility="Collapsed"
                  FontSize="{TemplateBinding FontSize}"
                  MinWidth="34"
                  VerticalAlignment="Stretch"/>
						<Button x:Name="QueryButton"
                  Grid.Row="1"
                  Style="{StaticResource QueryButtonStyle}"
                  BorderThickness="{TemplateBinding BorderThickness}"
                  Margin="{ThemeResource HelperButtonThemePadding}"
                  IsTabStop="False"
                  Grid.Column="2"
                  FontSize="{TemplateBinding FontSize}"
                  MinWidth="34"
                  VerticalAlignment="Stretch"/>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>