summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.WinRT.Phone/SearchBox.xaml
blob: 3b609fe86b368b57e5854f9d5b27e7763a452c14 (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
<Control
	x:Class="Xamarin.Forms.Platform.WinRT.SearchBox"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	xmlns:winRt="using:Xamarin.Forms.Platform.WinRT"
	mc:Ignorable="d"
	d:DesignHeight="300"
	d:DesignWidth="400">
	
	<Control.Resources>
		<ResourceDictionary>
			<ResourceDictionary.ThemeDictionaries>
				<ResourceDictionary x:Key="Default">
					<SolidColorBrush x:Key="SearchBoxBackgroundThemeBrush" Color="#CCFFFFFF" />
					<SolidColorBrush x:Key="SearchBoxBorderThemeBrush" Color="#FF2A2A2A" />
					<SolidColorBrush x:Key="SearchBoxDisabledBackgroundThemeBrush" Color="Transparent" />
					<SolidColorBrush x:Key="SearchBoxDisabledTextThemeBrush" Color="#66FFFFFF" />
					<SolidColorBrush x:Key="SearchBoxDisabledBorderThemeBrush" Color="#FF666666" />
					<SolidColorBrush x:Key="SearchBoxPointerOverBackgroundThemeBrush" Color="#DDFFFFFF" />
					<SolidColorBrush x:Key="SearchBoxPointerOverTextThemeBrush" Color="#99000000" />
					<SolidColorBrush x:Key="SearchBoxPointerOverBorderThemeBrush" Color="#FFDDDDDD" />
					<SolidColorBrush x:Key="SearchBoxFocusedBackgroundThemeBrush" Color="#FFFFFFFF" />
					<SolidColorBrush x:Key="SearchBoxFocusedTextThemeBrush" Color="#FF000000" />
					<SolidColorBrush x:Key="SearchBoxFocusedBorderThemeBrush" Color="#FF2A2A2A" />
					<SolidColorBrush x:Key="SearchBoxButtonBackgroundThemeBrush" Color="#FF4617B4" />
					<SolidColorBrush x:Key="SearchBoxButtonForegroundThemeBrush" Color="White" />
					<SolidColorBrush x:Key="SearchBoxButtonPointerOverForegroundThemeBrush" Color="White" />
					<SolidColorBrush x:Key="SearchBoxButtonPointerOverBackgroundThemeBrush" Color="#FF5F37BE" />
					<SolidColorBrush x:Key="SearchBoxSeparatorSuggestionForegroundThemeBrush" Color="Black" />
					<SolidColorBrush x:Key="SearchBoxHitHighlightForegroundThemeBrush" Color="#FF4617B4" />
					<SolidColorBrush x:Key="SearchBoxHitHighlightSelectedForegroundThemeBrush" Color="#FFA38BDA" />
					<SolidColorBrush x:Key="SearchBoxForegroundThemeBrush" Color="Black" />
				</ResourceDictionary>
			</ResourceDictionary.ThemeDictionaries>
			
			<x:Double x:Key="SearchBoxTextBoxThemeMinHeight">28</x:Double>
			<x:Double x:Key="SearchBoxContentThemeFontSize">15</x:Double>
			<Thickness x:Key="SearchBoxThemePadding">8,4,8,4</Thickness>
			<Thickness x:Key="SearchBoxBorderThemeThickness">2</Thickness>
			<FontWeight x:Key="SearchBoxButtonThemeFontWeight">Normal</FontWeight>
			<FontWeight x:Key="SearchBoxContentThemeFontWeight">Normal</FontWeight>
            <winRt:TextAlignmentToHorizontalAlignmentConverter x:Key="AlignmentConverter" />
		</ResourceDictionary>
	</Control.Resources>

	<Control.Style>
		<Style TargetType="Control">
			<Setter Property="Background" Value="{ThemeResource SearchBoxBackgroundThemeBrush}"/>
			<Setter Property="BorderBrush" Value="{ThemeResource SearchBoxBorderThemeBrush}"/>
			<Setter Property="BorderThickness" Value="{ThemeResource SearchBoxBorderThemeThickness}"/>
			<Setter Property="FontFamily" Value="{ThemeResource ContentControlThemeFontFamily}"/>
			<Setter Property="FontSize" Value="{ThemeResource SearchBoxContentThemeFontSize}"/>
			<Setter Property="FontWeight" Value="{ThemeResource SearchBoxContentThemeFontWeight}"/>
			<Setter Property="Foreground" Value="{ThemeResource SearchBoxForegroundThemeBrush}"/>
			<Setter Property="Padding" Value="{ThemeResource SearchBoxThemePadding}"/>
			<Setter Property="IsTabStop" Value="False"/>
			<Setter Property="Typography.StylisticSet20" Value="True"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate>
						<Grid x:Name="SearchBoxGrid">
							<Grid.Resources>
								<Style x:Key="SearchButtonStyle" TargetType="Button">
                                    <Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}"/>
									<Setter Property="IsTabStop" Value="False"/>
									<Setter Property="VerticalAlignment" Value="Stretch"/>
									<Setter Property="Template">
										<Setter.Value>
											<ControlTemplate TargetType="Button">
												<Grid Background="Transparent">
													<VisualStateManager.VisualStateGroups>
														<VisualStateGroup x:Name="CommonStates">
															<VisualState x:Name="Normal"/>
															<VisualState x:Name="PointerOver">
																<Storyboard>
																	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchGlyph">
																		<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonPointerOverForegroundThemeBrush}"/>
																	</ObjectAnimationUsingKeyFrames>
																	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchButtonBackground">
																		<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonPointerOverBackgroundThemeBrush}"/>
																	</ObjectAnimationUsingKeyFrames>
																</Storyboard>
															</VisualState>
															<VisualState x:Name="Pressed">
																<Storyboard>
																	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchGlyph">
																		<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedTextThemeBrush}"/>
																	</ObjectAnimationUsingKeyFrames>
																	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchButtonBackground">
																		<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedBackgroundThemeBrush}"/>
																	</ObjectAnimationUsingKeyFrames>
																</Storyboard>
															</VisualState>
															<VisualState x:Name="Disabled"/>
														</VisualStateGroup>
														<VisualStateGroup x:Name="FocusStates">
															<VisualState x:Name="Focused"/>
															<VisualState x:Name="Unfocused"/>
															<VisualState x:Name="PointerFocused"/>
														</VisualStateGroup>
													</VisualStateManager.VisualStateGroups>
													<Grid x:Name="SearchButtonBackground" Background="{TemplateBinding Background}">
														<SymbolIcon x:Name="SearchGlyph" Symbol="Find" AutomationProperties.AccessibilityView="Raw" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
													</Grid>
												</Grid>
											</ControlTemplate>
										</Setter.Value>
									</Setter>
								</Style>
								<Style x:Key="SearchTextBoxStyle" TargetType="winRt:FormsTextBox">
                                    <Setter Property="Margin" Value="0" />
									<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}"/>
                                    <Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}"/>
                                    <Setter Property="Foreground" Value="{ThemeResource TextBoxForegroundThemeBrush}"/>
									<Setter Property="Background" Value="{ThemeResource TextBoxBackgroundThemeBrush}"/>
									<Setter Property="BorderBrush" Value="{ThemeResource TextBoxBorderThemeBrush}"/>
                                    <Setter Property="PlaceholderForegroundBrush" Value="{ThemeResource TextBoxPlaceholderTextThemeBrush}"/>
									<Setter Property="SelectionHighlightColor" Value="{ThemeResource TextSelectionHighlightColorThemeBrush}"/>
									<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="winRt:FormsTextBox">
												<Grid>
													<VisualStateManager.VisualStateGroups>
														<VisualStateGroup x:Name="CommonStates">
															<VisualState x:Name="Disabled">
																<Storyboard>
																	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="BackgroundElement">
																		<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledBackgroundThemeBrush}"/>
																	</ObjectAnimationUsingKeyFrames>
																	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement">
																		<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledBorderThemeBrush}"/>
																	</ObjectAnimationUsingKeyFrames>
																	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentElement">
																		<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledForegroundThemeBrush}"/>
																	</ObjectAnimationUsingKeyFrames>
																	<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="PlaceholderTextContentPresenter">
																		<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledForegroundThemeBrush}"/>
																	</ObjectAnimationUsingKeyFrames>
																</Storyboard>
															</VisualState>
															<VisualState x:Name="Normal">
																<Storyboard>
																	<DoubleAnimation Duration="0" To="{ThemeResource TextControlBackgroundThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundElement"/>
																	<DoubleAnimation Duration="0" To="{ThemeResource TextControlBorderThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BorderElement"/>
																</Storyboard>
															</VisualState>
															<VisualState x:Name="PointerOver">
																<Storyboard>
																	<DoubleAnimation Duration="0" To="{ThemeResource TextControlPointerOverBackgroundThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundElement"/>
																	<DoubleAnimation Duration="0" To="{ThemeResource TextControlPointerOverBorderThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BorderElement"/>
																</Storyboard>
															</VisualState>
															<VisualState x:Name="Focused"/>
														</VisualStateGroup>
														<VisualStateGroup x:Name="ButtonStates"/>
													</VisualStateManager.VisualStateGroups>
                                                    
													<Border x:Name="BackgroundElement" Background="{TemplateBinding Background}" Margin="{TemplateBinding BorderThickness}" />
													<Border x:Name="BorderElement" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" />
													<ScrollViewer x:Name="ContentElement" AutomationProperties.AccessibilityView="Raw" HorizontalScrollMode="{TemplateBinding ScrollViewer.HorizontalScrollMode}" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" IsTabStop="False" IsHorizontalRailEnabled="{TemplateBinding ScrollViewer.IsHorizontalRailEnabled}" IsVerticalRailEnabled="{TemplateBinding ScrollViewer.IsVerticalRailEnabled}" IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}" Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" ZoomMode="Disabled"/>
                                                    <ContentControl x:Name="PlaceholderTextContentPresenter" Content="{TemplateBinding PlaceholderText}" Foreground="{TemplateBinding PlaceholderForegroundBrush}" IsHitTestVisible="False" IsTabStop="False" Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"  
                                                                    HorizontalAlignment="{Binding TextAlignment, 
                                                                        RelativeSource={RelativeSource Mode=TemplatedParent}, 
                                                                        Converter={StaticResource AlignmentConverter}}" />
												</Grid>
											</ControlTemplate>
										</Setter.Value>
									</Setter>
								</Style>
							</Grid.Resources>
							
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchBoxGrid">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Background, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="SearchBoxBorder">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding BorderBrush, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchButton">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{Binding Foreground, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Disabled">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchBoxGrid">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxDisabledBackgroundThemeBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="SearchBoxBorder">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxDisabledBorderThemeBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchButton">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxDisabledTextThemeBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchTextBox">
												<DiscreteObjectKeyFrame KeyTime="0" Value="Transparent"/>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Focused">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchBoxGrid">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedBackgroundThemeBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="SearchBoxBorder">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxFocusedBorderThemeBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="SearchButton">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonForegroundThemeBrush}"/>
											</ObjectAnimationUsingKeyFrames>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="SearchButton">
												<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SearchBoxButtonBackgroundThemeBrush}"/>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							
							<Border x:Name="SearchBoxBorder" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="Transparent">
								<Grid>
									<Grid.ColumnDefinitions>
										<ColumnDefinition/>
										<ColumnDefinition Width="Auto"/>
									</Grid.ColumnDefinitions>

                                    <winRt:FormsTextBox x:Name="SearchTextBox" BorderThickness="0" Background="Transparent" Text="{Binding Path=QueryText, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Foreground="{TemplateBinding Foreground}" FontWeight="{TemplateBinding FontWeight}" FontSize="{TemplateBinding FontSize}" FontFamily="{TemplateBinding FontFamily}" FontStyle="{TemplateBinding FontStyle}" InputScope="Search" MinHeight="{ThemeResource SearchBoxTextBoxThemeMinHeight}" MaxLength="2048" Padding="{TemplateBinding Padding}" Style="{StaticResource SearchTextBoxStyle}" TextWrapping="NoWrap" VerticalAlignment="Stretch"/>
									<Button x:Name="SearchButton" AutomationProperties.AccessibilityView="Raw" Background="Transparent" Grid.Column="1" FontWeight="{ThemeResource SearchBoxButtonThemeFontWeight}" Style="{StaticResource SearchButtonStyle}"/>
								</Grid>
							</Border>
						</Grid>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</Control.Style>
</Control>