summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.UAP/FormsTextBoxStyle.xaml
blob: c573552a124643d409b9b2711c8e562f5a299770 (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
<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">

	<uwp:TextAlignmentToHorizontalAlignmentConverter x:Key="AlignmentConverter" />
	<Style x:Key="FormsTextBoxStyle" TargetType="uwp:FormsTextBox">
		<Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}" />
		<Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}" />
		<Setter Property="Foreground" Value="{ThemeResource SystemControlForegroundBaseHighBrush}" />
		<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="PlaceholderForegroundBrush" Value="{ThemeResource SystemControlPageTextBaseMediumBrush}" />
		<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 x:Name="ButtonLayoutGrid" BorderBrush="{ThemeResource TextBoxButtonBorderThemeBrush}"
											      BorderThickness="{TemplateBinding BorderThickness}"
											      Background="{ThemeResource TextBoxButtonBackgroundThemeBrush}">
												<VisualStateManager.VisualStateGroups>
													<VisualStateGroup x:Name="CommonStates">
														<VisualState x:Name="Normal" />
														<VisualState x:Name="PointerOver">
															<Storyboard>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
																                               Storyboard.TargetName="GlyphElement">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
																</ObjectAnimationUsingKeyFrames>
															</Storyboard>
														</VisualState>
														<VisualState x:Name="Pressed">
															<Storyboard>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
																                               Storyboard.TargetName="ButtonLayoutGrid">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
																</ObjectAnimationUsingKeyFrames>
																<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
																                               Storyboard.TargetName="GlyphElement">
																	<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAltChromeWhiteBrush}" />
																</ObjectAnimationUsingKeyFrames>
															</Storyboard>
														</VisualState>
														<VisualState x:Name="Disabled">
															<Storyboard>
																<DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity"
																                 Storyboard.TargetName="ButtonLayoutGrid" />
															</Storyboard>
														</VisualState>
													</VisualStateGroup>
												</VisualStateManager.VisualStateGroups>
												<TextBlock x:Name="GlyphElement" AutomationProperties.AccessibilityView="Raw"
												           Foreground="{ThemeResource SystemControlForegroundChromeBlackMediumBrush}" FontStyle="Normal"
												           FontSize="12" FontFamily="{ThemeResource SymbolThemeFontFamily}" HorizontalAlignment="Center"
												           Text="&#xE10A;" VerticalAlignment="Center" />
											</Grid>
										</ControlTemplate>
									</Setter.Value>
								</Setter>
							</Style>
						</Grid.Resources>
						<Grid.ColumnDefinitions>
							<ColumnDefinition Width="*" />
							<ColumnDefinition Width="Auto" />
						</Grid.ColumnDefinitions>
						<Grid.RowDefinitions>
							<RowDefinition Height="Auto" />
							<RowDefinition Height="*" />
						</Grid.RowDefinitions>
						<VisualStateManager.VisualStateGroups>
							<VisualStateGroup x:Name="CommonStates">
								<VisualState x:Name="Disabled">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
										                               Storyboard.TargetName="HeaderContentPresenter">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
										                               Storyboard.TargetName="BackgroundElement">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledTransparentBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="BorderElement">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlBackgroundBaseLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledBaseLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentElement">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledChromeDisabledLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
										                               Storyboard.TargetName="PlaceholderTextContentPresenter">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlDisabledChromeDisabledLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Normal" />
								<VisualState x:Name="PointerOver">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightChromeAltLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundElement">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundHoverOpacity}" />
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="Focused">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
										                               Storyboard.TargetName="PlaceholderTextContentPresenter">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlPageTextChromeBlackMediumLowBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background"
										                               Storyboard.TargetName="BackgroundElement">
											<DiscreteObjectKeyFrame KeyTime="0"
											                        Value="{Binding BackgroundFocusBrush, RelativeSource={RelativeSource TemplatedParent}}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BackgroundElement">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextControlBackgroundFocusedOpacity}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentElement">
											<DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource SystemControlForegroundChromeBlackHighBrush}" />
										</ObjectAnimationUsingKeyFrames>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="RequestedTheme"
										                               Storyboard.TargetName="ContentElement">
											<DiscreteObjectKeyFrame KeyTime="0" Value="Light" />
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
							</VisualStateGroup>
							<VisualStateGroup x:Name="ButtonStates">
								<VisualState x:Name="ButtonVisible">
									<Storyboard>
										<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DeleteButton">
											<DiscreteObjectKeyFrame KeyTime="0">
												<DiscreteObjectKeyFrame.Value>
													<Visibility>Visible</Visibility>
												</DiscreteObjectKeyFrame.Value>
											</DiscreteObjectKeyFrame>
										</ObjectAnimationUsingKeyFrames>
									</Storyboard>
								</VisualState>
								<VisualState x:Name="ButtonCollapsed" />
							</VisualStateGroup>
						</VisualStateManager.VisualStateGroups>
						<Border x:Name="BackgroundElement" Background="{TemplateBinding Background}" Grid.ColumnSpan="2"
						        Margin="{TemplateBinding BorderThickness}" Opacity="{ThemeResource TextControlBackgroundRestOpacity}"
						        Grid.Row="1" Grid.RowSpan="1" />
						<Border x:Name="BorderElement" BorderBrush="{TemplateBinding BorderBrush}"
						        BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" Grid.Row="1" Grid.RowSpan="1" />
						<ContentPresenter x:Name="HeaderContentPresenter" Grid.ColumnSpan="2"
						                  ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}"
						                  Foreground="{ThemeResource SystemControlForegroundBaseHighBrush}" FontWeight="Normal"
						                  Margin="0,0,0,8" Grid.Row="0" Visibility="Collapsed" x:DeferLoadStrategy="Lazy" />
						<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}" Grid.Row="1"
						              VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
						              VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" ZoomMode="Disabled" />
						<ContentControl x:Name="PlaceholderTextContentPresenter" Grid.ColumnSpan="2"
						                Content="{TemplateBinding PlaceholderText}"
						                Foreground="{TemplateBinding PlaceholderForegroundBrush}" IsHitTestVisible="False"
						                IsTabStop="False" Margin="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}"
						                Grid.Row="1"
						                HorizontalAlignment="{Binding TextAlignment, 
                                            RelativeSource={RelativeSource Mode=TemplatedParent}, 
                                            Converter={StaticResource AlignmentConverter}}" />
						<Button x:Name="DeleteButton" BorderThickness="{TemplateBinding BorderThickness}" Grid.Column="1"
						        FontSize="{TemplateBinding FontSize}" IsTabStop="False" Margin="{ThemeResource HelperButtonThemePadding}"
						        MinWidth="34" Grid.Row="1" Style="{StaticResource DeleteButtonStyle}" Visibility="Collapsed"
						        VerticalAlignment="Stretch" />
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>