2025-07-11 09:20:23 +08:00
|
|
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
|
|
|
xmlns:controls="clr-namespace:AntdWpf.Controls"
|
|
|
|
|
xmlns:helpers="clr-namespace:AntdWpf.Helpers">
|
|
|
|
|
|
|
|
|
|
<ResourceDictionary.MergedDictionaries>
|
|
|
|
|
<ResourceDictionary Source="pack://application:,,,/AntdWpf;component/Styles/Converters.xaml" />
|
|
|
|
|
<ResourceDictionary Source="pack://application:,,,/AntdWpf;component/Styles/Animations.xaml" />
|
|
|
|
|
<ResourceDictionary Source="pack://application:,,,/AntdWpf;component/Styles/Input.xaml" />
|
|
|
|
|
</ResourceDictionary.MergedDictionaries>
|
|
|
|
|
|
|
|
|
|
<Style x:Key="Ant.TextBox" BasedOn="{StaticResource Ant.Input}" TargetType="{x:Type TextBox}">
|
|
|
|
|
<Setter Property="Template">
|
|
|
|
|
<Setter.Value>
|
|
|
|
|
<ControlTemplate TargetType="{x:Type TextBox}">
|
|
|
|
|
<Grid>
|
|
|
|
|
<!-- Input Effect -->
|
|
|
|
|
<Border x:Name="Effect"
|
|
|
|
|
Opacity="0"
|
|
|
|
|
Focusable="False"
|
|
|
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
|
|
|
BorderThickness="{DynamicResource OutlineThickness}"
|
2025-07-12 23:31:32 +08:00
|
|
|
CornerRadius="{TemplateBinding helpers:AntdControl.CornerRadius}"
|
2025-07-11 09:20:23 +08:00
|
|
|
Margin="{Binding BorderThickness, Mode=OneWay, RelativeSource={RelativeSource Self},
|
|
|
|
|
Converter={StaticResource ThicknessReverseConverter}}" />
|
|
|
|
|
<!-- Input -->
|
2025-07-12 23:31:32 +08:00
|
|
|
<controls:AntdBorder UseLayoutRounding="True"
|
2025-07-11 09:20:23 +08:00
|
|
|
Padding="{TemplateBinding Padding}"
|
|
|
|
|
Background="{TemplateBinding Background}"
|
|
|
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
|
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
|
|
|
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
2025-07-12 23:31:32 +08:00
|
|
|
BorderStyle="{TemplateBinding helpers:AntdControl.BorderStyle}"
|
|
|
|
|
CornerRadius="{TemplateBinding helpers:AntdControl.CornerRadius}">
|
2025-07-11 09:20:23 +08:00
|
|
|
<Grid>
|
|
|
|
|
<Grid.ColumnDefinitions>
|
|
|
|
|
<!-- Prefix -->
|
|
|
|
|
<ColumnDefinition Width="Auto" />
|
|
|
|
|
<!-- Input -->
|
|
|
|
|
<ColumnDefinition Width="*" />
|
|
|
|
|
<!-- Suffix -->
|
|
|
|
|
<ColumnDefinition Width="Auto" />
|
|
|
|
|
</Grid.ColumnDefinitions>
|
|
|
|
|
<!-- Prefix -->
|
|
|
|
|
<ContentPresenter x:Name="Prefix"
|
|
|
|
|
Grid.Column="0"
|
|
|
|
|
Margin="1 0 5 0"
|
|
|
|
|
Focusable="False"
|
|
|
|
|
Content="{TemplateBinding helpers:Input.Prefix}"
|
|
|
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
|
|
|
|
<!-- Placeholder -->
|
|
|
|
|
<TextBlock x:Name="Placeholder"
|
|
|
|
|
Grid.Column="1"
|
|
|
|
|
Focusable="False"
|
|
|
|
|
Visibility="Collapsed"
|
|
|
|
|
TextWrapping="{TemplateBinding TextWrapping}"
|
|
|
|
|
TextAlignment="{TemplateBinding TextAlignment}"
|
|
|
|
|
Text="{TemplateBinding helpers:Input.Placeholder}"
|
|
|
|
|
Foreground="{TemplateBinding helpers:Input.PlaceholderBrush}"
|
|
|
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
|
|
|
|
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" />
|
|
|
|
|
<!-- Input -->
|
|
|
|
|
<!-- TextBox will automatically handle padding, so you need to change the margin to a negative value. -->
|
|
|
|
|
<ScrollViewer x:Name="PART_ContentHost"
|
|
|
|
|
Grid.Column="1"
|
|
|
|
|
IsTabStop="False"
|
|
|
|
|
BorderThickness="0"
|
|
|
|
|
Background="{x:Null}"
|
|
|
|
|
Margin="{Binding Padding, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent},
|
|
|
|
|
Converter={StaticResource ThicknessReverseConverter}}" />
|
|
|
|
|
<!-- Suffix -->
|
|
|
|
|
<ContentPresenter x:Name="Suffix"
|
|
|
|
|
Grid.Column="2"
|
|
|
|
|
Margin="5 0 1 0"
|
|
|
|
|
Focusable="False"
|
|
|
|
|
Content="{TemplateBinding helpers:Input.Suffix}"
|
|
|
|
|
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
|
|
|
|
</Grid>
|
2025-07-12 23:31:32 +08:00
|
|
|
</controls:AntdBorder>
|
2025-07-11 09:20:23 +08:00
|
|
|
<VisualStateManager.VisualStateGroups>
|
|
|
|
|
<VisualStateGroup x:Name="FocusStates">
|
|
|
|
|
<VisualStateGroup.Transitions>
|
|
|
|
|
<VisualTransition GeneratedDuration="0:0:0.3" />
|
|
|
|
|
</VisualStateGroup.Transitions>
|
|
|
|
|
<VisualState x:Name="Focused" Storyboard="{StaticResource Ant.InputAnimating}" />
|
|
|
|
|
<VisualState x:Name="Unfocused" />
|
|
|
|
|
</VisualStateGroup>
|
|
|
|
|
</VisualStateManager.VisualStateGroups>
|
|
|
|
|
</Grid>
|
|
|
|
|
<ControlTemplate.Triggers>
|
|
|
|
|
<DataTrigger Binding="{Binding Text, Mode=OneWay, RelativeSource={RelativeSource Self}}" Value="">
|
|
|
|
|
<Setter TargetName="Placeholder" Property="Visibility" Value="Visible" />
|
|
|
|
|
</DataTrigger>
|
|
|
|
|
<!-- Prefix & Suffix -->
|
|
|
|
|
<Trigger SourceName="Prefix" Property="Content" Value="{x:Null}">
|
|
|
|
|
<Setter TargetName="Prefix" Property="Visibility" Value="Collapsed" />
|
|
|
|
|
</Trigger>
|
|
|
|
|
<Trigger SourceName="Suffix" Property="Content" Value="{x:Null}">
|
|
|
|
|
<Setter TargetName="Suffix" Property="Visibility" Value="Collapsed" />
|
|
|
|
|
</Trigger>
|
|
|
|
|
<MultiTrigger>
|
|
|
|
|
<MultiTrigger.Conditions>
|
|
|
|
|
<Condition Property="helpers:Input.Clearable" Value="True" />
|
|
|
|
|
<Condition SourceName="Placeholder" Property="Visibility" Value="Collapsed" />
|
|
|
|
|
</MultiTrigger.Conditions>
|
|
|
|
|
<Setter TargetName="Suffix" Property="Content">
|
|
|
|
|
<!--
|
|
|
|
|
How to customize Icon?
|
|
|
|
|
By setting up the locally-defined resource dictionary.
|
|
|
|
|
-->
|
|
|
|
|
<Setter.Value>
|
|
|
|
|
<controls:Icon Style="{StaticResource Ant.Clearable}" Type="close" helpers:Input.ClearEnabled="True" />
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
</MultiTrigger>
|
|
|
|
|
</ControlTemplate.Triggers>
|
|
|
|
|
</ControlTemplate>
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
</Style>
|
|
|
|
|
|
|
|
|
|
</ResourceDictionary>
|