Files
ShrlAlgoToolkit/WPFluent/Controls/ChooseBox/ChooseBox.xaml

157 lines
11 KiB
Plaintext
Raw Normal View History

2024-09-22 11:05:41 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2025-07-11 09:20:23 +08:00
xmlns:controls="clr-namespace:WPFluent.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
2024-09-22 11:05:41 +08:00
<ResourceDictionary.MergedDictionaries>
<!--<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Resources/DesignTime.xaml" />-->
<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Resources/Variables.xaml" />
2025-04-24 20:56:44 +08:00
<ResourceDictionary Source="pack://application:,,,/WPFluent;component/Controls/TextBox/TextBox.xaml" />
2024-09-22 11:05:41 +08:00
</ResourceDictionary.MergedDictionaries>
2025-07-11 09:20:23 +08:00
<PathGeometry Figures="M147.01175 430.890704c-44.791136 0-81.108273 36.303834-81.108273 81.109296 0 44.778856 36.316114 81.108273 81.108273 81.108273 44.792159 0 81.109296-36.329417 81.109296-81.108273C228.121046 467.194538 191.804932 430.890704 147.01175 430.890704zM511.999488 430.890704c-44.791136 0-81.108273 36.303834-81.108273 81.109296 0 44.778856 36.316114 81.108273 81.108273 81.108273 44.792159 0 81.109296-36.329417 81.109296-81.108273C593.108784 467.194538 556.791647 430.890704 511.999488 430.890704zM876.987227 430.890704c-44.791136 0-81.108273 36.303834-81.108273 81.109296 0 44.778856 36.316114 81.108273 81.108273 81.108273s81.108273-36.329417 81.108273-81.108273C958.094476 467.194538 921.778362 430.890704 876.987227 430.890704z" x:Key="Icon" />
<Style TargetType="Button" x:Key="ChooseButtonStyle">
2025-05-05 17:04:06 +08:00
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<Path
2025-07-11 09:20:23 +08:00
Data="{StaticResource Icon}"
Fill="{DynamicResource TextControlElevationBorderBrush}"
2025-05-05 17:04:06 +08:00
HorizontalAlignment="Left"
2025-07-11 09:20:23 +08:00
Stretch="Uniform"
2025-05-05 17:04:06 +08:00
VerticalAlignment="Center"
2025-07-11 09:20:23 +08:00
Width="12"
x:Name="icon" />
2025-05-05 17:04:06 +08:00
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Cursor" Value="Hand" />
2025-07-11 09:20:23 +08:00
<Setter Property="Fill" TargetName="icon" Value="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}" />
2025-05-05 17:04:06 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type controls:ChooseBox}">
2025-07-11 09:20:23 +08:00
<Setter Property="Background" Value="{DynamicResource ControlFillColorDefaultBrush}" />
2025-05-05 17:04:06 +08:00
<Setter Property="Border.CornerRadius" Value="{StaticResource ControlCornerRadius}" />
2024-09-22 11:05:41 +08:00
<Setter Property="BorderBrush" Value="{DynamicResource TextControlElevationBorderBrush}" />
<Setter Property="BorderThickness" Value="{StaticResource TextBoxBorderThemeThickness}" />
2025-05-05 17:04:06 +08:00
<Setter Property="ChooseButtonWidth" Value="20" />
<Setter Property="FontSize" Value="{StaticResource ControlContentThemeFontSize}" />
2025-07-11 09:20:23 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextFillColorPrimaryBrush}" />
<Setter Property="ContextMenu" Value="{DynamicResource DefaultControlContextMenu}" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource DefaultControlFocusVisualStyle}" />
2025-05-05 17:04:06 +08:00
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="MinHeight" Value="{StaticResource TextControlThemeMinHeight}" />
<Setter Property="MinWidth" Value="{StaticResource TextControlThemeMinWidth}" />
<Setter Property="Padding" Value="{StaticResource TextControlThemePadding}" />
2024-09-22 11:05:41 +08:00
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
2025-05-05 17:04:06 +08:00
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="SnapsToDevicePixels" Value="True" />
2024-09-22 11:05:41 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:ChooseBox}">
2024-09-22 11:05:41 +08:00
<Grid>
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
2025-05-05 17:04:06 +08:00
CornerRadius="{TemplateBinding Border.CornerRadius}"
2025-07-11 09:20:23 +08:00
HorizontalAlignment="Stretch"
MinHeight="{TemplateBinding MinHeight}"
MinWidth="{TemplateBinding MinWidth}"
2025-05-05 17:04:06 +08:00
Name="ContentBorder"
2025-07-11 09:20:23 +08:00
Padding="0"
VerticalAlignment="Stretch">
2024-09-22 11:05:41 +08:00
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
2025-05-05 17:04:06 +08:00
<TextBlock
2025-07-11 09:20:23 +08:00
FontSize="{TemplateBinding FontSize}"
Foreground="{DynamicResource TextFillColorSecondaryBrush}"
2025-05-05 17:04:06 +08:00
Margin="0"
Name="PlaceholderTextBlock"
Padding="4,0"
Text="{TemplateBinding PlaceholderText}"
2025-07-11 09:20:23 +08:00
VerticalAlignment="Center"
Visibility="Collapsed" />
2024-09-22 11:05:41 +08:00
<controls:PassiveScrollViewer
2025-07-11 09:20:23 +08:00
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
2024-09-22 11:05:41 +08:00
Foreground="{TemplateBinding Foreground}"
2025-07-11 09:20:23 +08:00
Grid.Column="0"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
2024-09-22 11:05:41 +08:00
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}"
2025-07-11 09:20:23 +08:00
Margin="{TemplateBinding Padding}"
Style="{DynamicResource DefaultTextBoxScrollViewerStyle}"
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
x:Name="PART_ContentHost" />
2024-09-22 11:05:41 +08:00
<Button
2025-07-11 09:20:23 +08:00
Foreground="{TemplateBinding Foreground}"
2024-09-22 11:05:41 +08:00
Grid.Column="1"
2025-07-11 09:20:23 +08:00
Style="{StaticResource ChooseButtonStyle}"
2024-09-22 11:05:41 +08:00
Width="{TemplateBinding ChooseButtonWidth}"
2025-07-11 09:20:23 +08:00
x:Name="PART_ChooseButton" />
2024-09-22 11:05:41 +08:00
</Grid>
</Border>
<Border
BorderBrush="{DynamicResource ControlStrokeColorDefaultBrush}"
BorderThickness="{StaticResource TextBoxAccentBorderThemeThickness}"
2025-05-05 17:04:06 +08:00
CornerRadius="{TemplateBinding Border.CornerRadius}"
2025-07-11 09:20:23 +08:00
Grid.ColumnSpan="2"
HorizontalAlignment="Stretch"
Name="AccentBorder"
VerticalAlignment="Stretch" />
2024-09-22 11:05:41 +08:00
</Grid>
<ControlTemplate.Triggers>
<!--<Trigger Property="IsKeyboardFocused" Value="true">
<Setter TargetName="bordermove" Property="Opacity" Value="1" />
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="bordermove" Property="Opacity" Value="1" />
</Trigger>-->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="True" />
<Condition Property="UIElement.IsMouseOver" Value="True" />
<Condition Property="UIElement.IsFocused" Value="False" />
</MultiTrigger.Conditions>
2025-07-11 09:20:23 +08:00
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorSecondaryBrush}" />
2024-09-22 11:05:41 +08:00
</MultiTrigger>
2025-05-05 17:04:06 +08:00
<Trigger Property="Text" Value="">
2025-07-11 09:20:23 +08:00
<Setter Property="Visibility" TargetName="PlaceholderTextBlock" Value="Visible" />
2025-05-05 17:04:06 +08:00
</Trigger>
2024-09-22 11:05:41 +08:00
<Trigger Property="IsEnabled" Value="False">
2025-07-11 09:20:23 +08:00
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorDisabledBrush}" />
<Setter Property="BorderBrush" TargetName="ContentBorder" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
<Setter Property="BorderBrush" TargetName="AccentBorder" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />
<Setter Property="controls:TextBoxEx.ClearButtonEnabled" Value="False" />
2025-07-11 09:20:23 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextFillColorDisabledBrush}" />
2024-09-22 11:05:41 +08:00
</Trigger>
<Trigger Property="UIElement.IsFocused" Value="True">
2025-07-11 09:20:23 +08:00
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlFillColorInputActiveBrush}" />
<Setter Property="BorderBrush" TargetName="AccentBorder" Value="{DynamicResource SystemFillColorAttentionBrush}" />
<Setter Property="BorderThickness" TargetName="AccentBorder" Value="0,0,0,2" />
2024-09-22 11:05:41 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
2025-07-11 09:20:23 +08:00
<Setter Property="CaretBrush" Value="{DynamicResource TextFillColorPrimaryBrush}" />
2025-05-05 17:04:06 +08:00
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
2024-09-22 11:05:41 +08:00
</Style>
</ResourceDictionary>