功能更新
This commit is contained in:
253
Melskin/Controls/ChooseBox.xaml
Normal file
253
Melskin/Controls/ChooseBox.xaml
Normal file
@@ -0,0 +1,253 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:controls="clr-namespace:Melskin.Controls"
|
||||
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style TargetType="{x:Type controls:ChooseBox}" x:Key="SlotChooseBoxStyle">
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="Border.CornerRadius" Value="4" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="ChooseButtonWidth" Value="20" />
|
||||
<Setter Property="PlaceholderText" Value="请选择..." />
|
||||
<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="150" />
|
||||
<Setter Property="Padding" Value="3" />
|
||||
<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>
|
||||
<decorations:SlotBorder
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding Border.CornerRadius}"
|
||||
HorizontalAlignment="Stretch"
|
||||
Intensity="0.2"
|
||||
MinHeight="{TemplateBinding MinHeight}"
|
||||
MinWidth="{TemplateBinding MinWidth}"
|
||||
Padding="0"
|
||||
VerticalAlignment="Stretch"
|
||||
x:Name="ContentBorder">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
Foreground="{DynamicResource TextPlaceholderBrush}"
|
||||
Grid.Column="0"
|
||||
Margin="5,0,0,0"
|
||||
Name="PlaceholderTextBlock"
|
||||
Text="{TemplateBinding PlaceholderText}"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Collapsed" />
|
||||
<ScrollViewer
|
||||
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Grid.Column="0"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||
IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||
x:Name="PART_ContentHost" />
|
||||
<Button
|
||||
Background="Transparent"
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
Grid.Column="1"
|
||||
Padding="0,0,4,0"
|
||||
Style="{DynamicResource FlattenButtonStyle}"
|
||||
Width="{TemplateBinding ChooseButtonWidth}"
|
||||
x:Name="PART_ChooseButton">
|
||||
<controls:IconElement
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
Symbol="MoreHoriz"
|
||||
x:Name="icon" />
|
||||
</Button>
|
||||
</Grid>
|
||||
</decorations:SlotBorder>
|
||||
<!--<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" />
|
||||
<!--<Condition Property="UIElement.IsFocused" Value="False" />-->
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Intensity" TargetName="ContentBorder" Value="0.5" />
|
||||
</MultiTrigger>
|
||||
<Trigger Property="Text" Value="">
|
||||
<Setter Property="Visibility" TargetName="PlaceholderTextBlock" Value="Visible" />
|
||||
</Trigger>
|
||||
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter Property="ShaderEnabled" TargetName="ContentBorder" Value="False" />
|
||||
<!--<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter TargetName="ContentBorder" Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />-->
|
||||
<!--<Setter Property="BorderBrush" TargetName="AccentBorder" Value="{DynamicResource ControlStrokeColorDefaultBrush}" />-->
|
||||
<!-- <Setter Property="controls:TextBoxEx.ClearButtonEnabled" Value="False" /> -->
|
||||
<!--<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />-->
|
||||
</Trigger>
|
||||
<!--<Trigger Property="UIElement.IsFocused" Value="True">
|
||||
<Setter TargetName="ContentBorder" Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
-->
|
||||
<!--<Setter Property="BorderBrush" TargetName="AccentBorder" Value="{DynamicResource SystemFillColorAttentionBrush}" />-->
|
||||
<!--<Setter Property="BorderThickness" TargetName="AccentBorder" Value="0,0,0,2" />-->
|
||||
<!--
|
||||
</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>
|
||||
<Style TargetType="{x:Type controls:ChooseBox}">
|
||||
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
||||
<Setter Property="Border.CornerRadius" Value="4" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="PlaceholderText" Value="请选择..." />
|
||||
<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" />
|
||||
<Setter Property="Padding" Value="3" />
|
||||
<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
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding Border.CornerRadius}"
|
||||
HorizontalAlignment="Stretch"
|
||||
MinHeight="{TemplateBinding MinHeight}"
|
||||
MinWidth="{TemplateBinding MinWidth}"
|
||||
Padding="0"
|
||||
VerticalAlignment="Stretch"
|
||||
x:Name="ContentBorder">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock
|
||||
FontSize="{TemplateBinding FontSize}"
|
||||
Foreground="{DynamicResource TextPlaceholderBrush}"
|
||||
Margin="5,0,0,0"
|
||||
Name="PlaceholderTextBlock"
|
||||
Text="{TemplateBinding PlaceholderText}"
|
||||
VerticalAlignment="Center"
|
||||
Visibility="Collapsed" />
|
||||
<ScrollViewer
|
||||
CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
Grid.Column="0"
|
||||
HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}"
|
||||
IsDeferredScrollingEnabled="{TemplateBinding ScrollViewer.IsDeferredScrollingEnabled}"
|
||||
IsTabStop="{TemplateBinding ScrollViewer.IsTabStop}"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}"
|
||||
x:Name="PART_ContentHost" />
|
||||
<Button
|
||||
Background="Transparent"
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
Grid.Column="1"
|
||||
Padding="0,0,4,0"
|
||||
Style="{DynamicResource FlattenButtonStyle}"
|
||||
Width="{TemplateBinding ChooseButtonWidth}"
|
||||
x:Name="PART_ChooseButton">
|
||||
<controls:IconElement
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
Symbol="MoreHoriz"
|
||||
x:Name="icon" />
|
||||
</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">
|
||||
<Setter Property="BorderBrush" TargetName="ContentBorder" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="ContentBorder" Value="{DynamicResource PrimaryNormalBrush}" />
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsEnabled" Value="True" />
|
||||
<Condition Property="UIElement.IsMouseOver" Value="True" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Background" TargetName="ContentBorder" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
||||
</MultiTrigger>
|
||||
<Trigger Property="Text" Value="">
|
||||
<Setter Property="Visibility" TargetName="PlaceholderTextBlock" Value="Visible" />
|
||||
</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>
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user