Files
ShrlAlgoToolkit/Melskin/Controls/ChooseBox.xaml

253 lines
16 KiB
Plaintext
Raw Normal View History

2025-08-12 23:08:54 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2026-02-20 15:31:44 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
2026-01-02 17:30:41 +08:00
xmlns:controls="clr-namespace:Melskin.Controls"
2026-02-20 15:31:44 +08:00
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations">
2026-02-20 15:31:44 +08:00
<Style x:Key="SlotChooseBoxStyle" TargetType="{x:Type controls:ChooseBox}">
2025-08-24 13:49:55 +08:00
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-12 23:08:54 +08:00
<Setter Property="Border.CornerRadius" Value="4" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="ChooseButtonWidth" Value="20" />
2025-12-28 11:47:54 +08:00
<Setter Property="PlaceholderText" Value="请选择..." />
2025-08-12 23:08:54 +08:00
<Setter Property="FontSize" Value="14" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="ContextMenu" Value="{DynamicResource TextBoxContextMenu}" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
2025-12-28 11:47:54 +08:00
<Setter Property="MinWidth" Value="150" />
2025-08-20 12:10:13 +08:00
<Setter Property="Padding" Value="3" />
2025-08-12 23:08:54 +08:00
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:ChooseBox}">
<Grid>
2025-09-04 22:39:00 +08:00
<decorations:SlotBorder
2026-02-20 15:31:44 +08:00
x:Name="ContentBorder"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}"
Padding="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
2025-08-12 23:08:54 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}"
2026-02-20 15:31:44 +08:00
Intensity="0.2">
2025-08-12 23:08:54 +08:00
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<TextBlock
2026-02-20 15:31:44 +08:00
Name="PlaceholderTextBlock"
2026-01-02 17:30:30 +08:00
Grid.Column="0"
Margin="5,0,0,0"
VerticalAlignment="Center"
2026-02-20 15:31:44 +08:00
FontSize="{TemplateBinding FontSize}"
Foreground="{DynamicResource TextPlaceholderBrush}"
Text="{TemplateBinding PlaceholderText}"
2025-08-12 23:08:54 +08:00
Visibility="Collapsed" />
<ScrollViewer
2026-02-20 15:31:44 +08:00
x:Name="PART_ContentHost"
Grid.Column="0"
Margin="{TemplateBinding Padding}"
2025-08-12 23:08:54 +08:00
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
Foreground="{TemplateBinding Foreground}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}"
2026-02-20 15:31:44 +08:00
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
2025-08-12 23:08:54 +08:00
<Button
2026-02-20 15:31:44 +08:00
x:Name="PART_ChooseButton"
2026-01-02 17:30:30 +08:00
Grid.Column="1"
Width="{TemplateBinding ChooseButtonWidth}"
2026-02-20 15:31:44 +08:00
Padding="0,0,4,0"
Background="Transparent"
Foreground="{DynamicResource TextSecondaryBrush}"
Style="{DynamicResource FlattenButtonStyle}">
<controls:IconElement
2026-02-20 15:31:44 +08:00
x:Name="icon"
Foreground="{DynamicResource TextSecondaryBrush}"
2026-02-20 15:31:44 +08:00
Symbol="MoreHoriz" />
2025-08-20 12:10:13 +08:00
</Button>
2025-08-12 23:08:54 +08:00
</Grid>
2025-09-04 22:39:00 +08:00
</decorations:SlotBorder>
2025-08-12 23:08:54 +08:00
<!--<Border
BorderBrush="Transparent"
BorderThickness="1"
CornerRadius="{TemplateBinding Border.CornerRadius}"
Grid.ColumnSpan="2"
HorizontalAlignment="Stretch"
Name="AccentBorder"
VerticalAlignment="Stretch" />-->
</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" />
2025-08-20 12:10:13 +08:00
<!--<Condition Property="UIElement.IsFocused" Value="False" />-->
2025-08-12 23:08:54 +08:00
</MultiTrigger.Conditions>
2026-02-20 15:31:44 +08:00
<Setter TargetName="ContentBorder" Property="Intensity" Value="0.5" />
2025-08-12 23:08:54 +08:00
</MultiTrigger>
<Trigger Property="Text" Value="">
2026-02-20 15:31:44 +08:00
<Setter TargetName="PlaceholderTextBlock" Property="Visibility" Value="Visible" />
2025-08-12 23:08:54 +08:00
</Trigger>
2025-08-20 12:10:13 +08:00
2025-08-12 23:08:54 +08:00
<Trigger Property="IsEnabled" Value="False">
2025-08-20 12:10:13 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
2026-02-20 15:31:44 +08:00
<Setter TargetName="ContentBorder" Property="ShaderEnabled" Value="False" />
2025-08-20 12:10:13 +08:00
<!--<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />-->
2025-08-12 23:08:54 +08:00
<!--<Setter Property="BorderBrush" TargetName="AccentBorder" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />-->
<!-- <Setter Property="controls:TextBoxEx.ClearButtonEnabled" Value="False" /> -->
2025-08-20 12:10:13 +08:00
<!--<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />-->
2025-08-12 23:08:54 +08:00
</Trigger>
2025-08-20 12:10:13 +08:00
<!--<Trigger Property="UIElement.IsFocused" Value="True">
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-20 12:10:13 +08:00
-->
<!--<Setter Property="BorderBrush" TargetName="AccentBorder" Value="{DynamicResource SystemFillColorAttentionBrush}" />-->
<!--<Setter Property="BorderThickness" TargetName="AccentBorder" Value="0,0,0,2" />-->
<!--
</Trigger>-->
2025-08-12 23:08:54 +08:00
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="CaretBrush" Value="{DynamicResource TextSecondaryBrush}" />
2025-08-12 23:08:54 +08:00
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
</Style>
2025-12-23 21:35:54 +08:00
<Style TargetType="{x:Type controls:ChooseBox}">
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="Border.CornerRadius" Value="4" />
<Setter Property="BorderBrush" Value="Transparent" />
2025-12-28 11:47:54 +08:00
<Setter Property="PlaceholderText" Value="请选择..." />
2025-12-23 21:35:54 +08:00
<Setter Property="BorderThickness" Value="1" />
<Setter Property="ChooseButtonWidth" Value="20" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="ContextMenu" Value="{DynamicResource TextBoxContextMenu}" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="MinWidth" Value="200" />
2026-02-22 20:03:42 +08:00
<Setter Property="Padding" Value="4" />
2025-12-23 21:35:54 +08:00
<Setter Property="ScrollViewer.CanContentScroll" Value="False" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" />
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Hidden" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:ChooseBox}">
<Grid>
<Border
2026-02-20 15:31:44 +08:00
x:Name="ContentBorder"
2026-01-02 17:30:30 +08:00
MinWidth="{TemplateBinding MinWidth}"
2026-02-20 15:31:44 +08:00
MinHeight="{TemplateBinding MinHeight}"
2026-02-22 20:03:42 +08:00
Padding="{TemplateBinding Padding}"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Stretch"
2026-01-02 17:30:30 +08:00
VerticalAlignment="Stretch"
2026-02-20 15:31:44 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding Border.CornerRadius}">
2025-12-23 21:35:54 +08:00
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<TextBlock
2026-02-20 15:31:44 +08:00
Name="PlaceholderTextBlock"
Margin="5,0,0,0"
VerticalAlignment="Center"
2026-02-22 20:03:42 +08:00
Focusable="False"
2025-12-23 21:35:54 +08:00
FontSize="{TemplateBinding FontSize}"
Foreground="{DynamicResource TextPlaceholderBrush}"
Text="{TemplateBinding PlaceholderText}"
Visibility="Collapsed" />
<ScrollViewer
2026-02-20 15:31:44 +08:00
x:Name="PART_ContentHost"
Grid.Column="0"
2025-12-23 21:35:54 +08:00
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
Foreground="{TemplateBinding Foreground}"
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}"
2026-02-20 15:31:44 +08:00
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}" />
2025-12-23 21:35:54 +08:00
<Button
2026-02-20 15:31:44 +08:00
x:Name="PART_ChooseButton"
2026-01-02 17:30:30 +08:00
Grid.Column="1"
Width="{TemplateBinding ChooseButtonWidth}"
2026-02-20 15:31:44 +08:00
Padding="0,0,4,0"
Background="Transparent"
Foreground="{DynamicResource TextSecondaryBrush}"
Style="{DynamicResource FlattenButtonStyle}">
2025-12-23 21:35:54 +08:00
<controls:IconElement
2026-02-20 15:31:44 +08:00
x:Name="icon"
2025-12-23 21:35:54 +08:00
Foreground="{DynamicResource TextSecondaryBrush}"
2026-02-20 15:31:44 +08:00
Symbol="MoreHoriz" />
2025-12-23 21:35:54 +08:00
</Button>
</Grid>
</Border>
<!--<Border
BorderBrush="Transparent"
BorderThickness="1"
CornerRadius="{TemplateBinding Border.CornerRadius}"
Grid.ColumnSpan="2"
HorizontalAlignment="Stretch"
Name="AccentBorder"
VerticalAlignment="Stretch" />-->
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocused" Value="true">
2026-02-20 15:31:44 +08:00
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
2025-12-23 21:35:54 +08:00
</Trigger>
<Trigger Property="IsMouseOver" Value="true">
2026-02-20 15:31:44 +08:00
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
2025-12-23 21:35:54 +08:00
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsEnabled" Value="True" />
<Condition Property="UIElement.IsMouseOver" Value="True" />
</MultiTrigger.Conditions>
2026-02-20 15:31:44 +08:00
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
2025-12-23 21:35:54 +08:00
</MultiTrigger>
<Trigger Property="Text" Value="">
2026-02-20 15:31:44 +08:00
<Setter TargetName="PlaceholderTextBlock" Property="Visibility" Value="Visible" />
2025-12-23 21:35:54 +08:00
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter Property="Cursor" Value="None" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="CaretBrush" Value="{DynamicResource TextSecondaryBrush}" />
<Setter Property="UseLayoutRounding" Value="True" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
</Style>
2025-08-12 23:08:54 +08:00
</ResourceDictionary>