diff options
Diffstat (limited to 'Xamarin.Forms.Platform.WinRT.Phone/FormsTextBoxStyle.xaml')
-rw-r--r-- | Xamarin.Forms.Platform.WinRT.Phone/FormsTextBoxStyle.xaml | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.WinRT.Phone/FormsTextBoxStyle.xaml b/Xamarin.Forms.Platform.WinRT.Phone/FormsTextBoxStyle.xaml new file mode 100644 index 00000000..521a9059 --- /dev/null +++ b/Xamarin.Forms.Platform.WinRT.Phone/FormsTextBoxStyle.xaml @@ -0,0 +1,121 @@ +<ResourceDictionary + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:forms="using:Xamarin.Forms.Platform.WinRT" + xmlns:system="using:System"> + + <forms:TextAlignmentToHorizontalAlignmentConverter x:Key="AlignmentConverter" /> + + <Style x:Key="FormsTextBoxStyle" TargetType="forms:FormsTextBox"> + <Setter Property="MinWidth" Value="{ThemeResource TextControlThemeMinWidth}"/> + <Setter Property="MinHeight" Value="{ThemeResource TextControlThemeMinHeight}"/> + <Setter Property="Foreground" Value="{ThemeResource TextBoxForegroundThemeBrush}"/> + <Setter Property="SelectionHighlightColor" Value="{ThemeResource TextSelectionHighlightColorThemeBrush}"/> + <Setter Property="Background" Value="{ThemeResource TextBoxBackgroundThemeBrush}"/> + <Setter Property="BackgroundFocusBrush" Value="{ThemeResource TextBoxFocusedBackgroundThemeBrush}"/> + <Setter Property="BorderBrush" Value="{ThemeResource TextBoxBorderThemeBrush}"/> + <Setter Property="BorderThickness" Value="0"/> + <Setter Property="FontFamily" Value="{ThemeResource PhoneFontFamilyNormal}"/> + <Setter Property="FontSize" Value="{ThemeResource ContentControlFontSize}"/> + <Setter Property="PlaceholderForegroundBrush" Value="{ThemeResource TextBoxPlaceholderTextThemeBrush}" /> + <Setter Property="TextWrapping" Value="NoWrap"/> + <Setter Property="ScrollViewer.HorizontalScrollMode" Value="Auto"/> + <Setter Property="ScrollViewer.VerticalScrollMode" Value="Auto"/> + <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="Margin" Value="0"/> + <Setter Property="VerticalAlignment" Value="Top"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="forms:FormsTextBox"> + <Grid Background="Transparent"> + <Grid.RowDefinitions> + <RowDefinition Height="Auto"/> + <RowDefinition Height="*"/> + </Grid.RowDefinitions> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualState x:Name="Disabled"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="BorderElement"> + <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> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="HeaderContentPresenter"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextBoxDisabledHeaderForegroundThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Normal"> + <Storyboard> + <DoubleAnimation Duration="0" To="{ThemeResource TextControlBorderThemeOpacity}" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="BorderElement"/> + </Storyboard> + </VisualState> + <VisualState x:Name="Focused"> + <Storyboard> + <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="BorderBrush" Storyboard.TargetName="BorderElement"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{ThemeResource TextSelectionHighlightColorThemeBrush}"/> + </ObjectAnimationUsingKeyFrames> + <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PlaceholderTextContentPresenter"/> + <!-- The commented-out section below *should* work, at least according to the docs and examples; but + instead it just crashes the application as soon as you focus a textbox. So the forms textbox class handles this + state manually in the phone version. I'm leaving this here in case someone can figure it out, because the VSM + is a much more elegant solution. (e.g., see the UWP project, where this *does* work) --> + <!--<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Background" Storyboard.TargetName="BorderElement"> + <DiscreteObjectKeyFrame KeyTime="0" Value="{Binding BackgroundFocusBrush, RelativeSource={RelativeSource TemplatedParent}}"/> + </ObjectAnimationUsingKeyFrames>--> + </Storyboard> + </VisualState> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + <Border x:Name="BorderElement" + BorderBrush="{TemplateBinding BorderBrush}" + Background="{TemplateBinding Background}" + BorderThickness="{TemplateBinding BorderThickness}" + Grid.Row="1"/> + <ContentPresenter x:Name="HeaderContentPresenter" + ContentTemplate="{TemplateBinding HeaderTemplate}" + Content="{TemplateBinding Header}" + Margin="{ThemeResource TextControlHeaderMarginThemeThickness}" + Grid.Row="0" Style="{StaticResource HeaderContentPresenterStyle}"/> + <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}" + MinHeight="{ThemeResource TextControlThemeMinHeight}" + Padding="{TemplateBinding Padding}" + Grid.Row="1" + FontSize="{ThemeResource ContentControlFontSize}" + VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" + VerticalScrollMode="{TemplateBinding ScrollViewer.VerticalScrollMode}" + ZoomMode="Disabled"/> + <ContentControl x:Name="PlaceholderTextContentPresenter" + Content="{TemplateBinding PlaceholderText}" + Foreground="{TemplateBinding PlaceholderForegroundBrush}" + FontSize="{ThemeResource ContentControlFontSize}" + IsTabStop="False" + Margin="{ThemeResource RichEditBoxTextThemeMargin}" + Padding="{TemplateBinding Padding}" + Grid.Row="1" + HorizontalAlignment="{Binding TextAlignment, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource AlignmentConverter}}"/> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> +</ResourceDictionary>
\ No newline at end of file |