248 строки
18 KiB
XML
248 строки
18 KiB
XML
<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> |