功能更新

This commit is contained in:
GG Z
2026-02-12 21:29:00 +08:00
parent a9faf251be
commit 5f1adc5ad2
341 changed files with 4293 additions and 1874 deletions

View File

@@ -0,0 +1,252 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:assists="clr-namespace:Melskin.Assists"
xmlns:controls="clr-namespace:Melskin.Controls"
xmlns:converters="clr-namespace:Melskin.Converters"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Melskin;component/Controls/ComboBox.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style TargetType="{x:Type ListBoxItem}" x:Key="MultiComboBoxItemStyle">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Padding" Value="12,4,8,4" />
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid>
<!--<ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center" />-->
<Border
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
Padding="{TemplateBinding Padding}"
SnapsToDevicePixels="True"
x:Name="Bd">
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Border>
<Border
CornerRadius="4"
Visibility="Hidden"
x:Name="Indicator">
<Border
Background="{DynamicResource PrimaryNormalBrush}"
CornerRadius="2"
HorizontalAlignment="Left"
Margin="2,4"
Width="4" />
</Border>
<!--<controls:IconElement
x:Name="CheckMark"
HorizontalAlignment="Right"
VerticalAlignment="Center"
FontWeight="Bold"
Foreground="{DynamicResource PrimaryNormalBrush}"
Symbol="Check"
Visibility="Collapsed" />-->
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
<Setter Property="Visibility" TargetName="Indicator" Value="Visible" />
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBackgroundHoverBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type controls:MultiComboBox}">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="12,8" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="assists:InputAssist.Clearable" Value="True" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="ScrollViewer.CanContentScroll" Value="True" />
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:MultiComboBox}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="10" />
</Grid.ColumnDefinitions>
<ToggleButton
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Grid.Column="0"
Grid.ColumnSpan="2"
IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
Style="{DynamicResource ComboBoxToggleButton}"
x:Name="PART_ToggleButton" />
<Grid
ClipToBounds="True"
Grid.Column="0"
Margin="{TemplateBinding BorderThickness}"
VerticalAlignment="Center"
x:Name="templateRoot">
<!-- 占位符 水印 -->
<TextBlock
Foreground="{DynamicResource TextPlaceholderBrush}"
IsHitTestVisible="False"
Margin="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
Text="{Binding PlaceHolderText, RelativeSource={RelativeSource AncestorType=controls:MultiComboBox}}"
VerticalAlignment="Center"
x:Name="PlaceholderTextBlock">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<!-- 多选:无标签 -->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding SelectionMode, RelativeSource={RelativeSource AncestorType=controls:MultiComboBox}}" Value="{x:Static SelectionMode.Multiple}" />
<Condition Binding="{Binding HasItems, ElementName=TagItemsControl}" Value="False" />
<!--<Condition Binding="{Binding SelectedItems.Count, RelativeSource={RelativeSource AncestorType=local:NeuComboBox}, TargetNullValue=0}" Value="0" />-->
</MultiDataTrigger.Conditions>
<Setter Property="Visibility" Value="Visible" />
</MultiDataTrigger>
<!-- 单选:未选 -->
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding SelectionMode, RelativeSource={RelativeSource AncestorType=controls:MultiComboBox}}" Value="{x:Static SelectionMode.Single}" />
<Condition Binding="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=controls:MultiComboBox}}" Value="{x:Null}" />
</MultiDataTrigger.Conditions>
<Setter Property="Visibility" Value="Visible" />
</MultiDataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
<!-- 多选 Tag 列表 -->
<!--<ItemsControl x:Name="TagItemsControl" ItemsSource="{Binding SelectedItems, Mode=OneWay, RelativeSource={RelativeSource AncestorType=local:NeuComboBox}}">-->
<ItemsControl ItemsSource="{Binding ElementName=PART_ListBox, Path=SelectedItems}" x:Name="TagItemsControl">
<ItemsControl.Style>
<Style TargetType="ItemsControl">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding SelectionMode, RelativeSource={RelativeSource AncestorType=controls:MultiComboBox}}" Value="{x:Static SelectionMode.Multiple}">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</ItemsControl.Style>
<!-- 标签滚动但是有bug 影响选择 -->
<!--<ItemsControl.Template>
<ControlTemplate>
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<ItemsPresenter />
</ScrollViewer>
</ControlTemplate>
</ItemsControl.Template>-->
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel IsItemsHost="True" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<controls:Tag
Closable="True"
Content="{Binding}"
Margin="1" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ContentPresenter
Content="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType=controls:MultiComboBox}}"
ContentStringFormat="{Binding DisplayMemberPath, RelativeSource={RelativeSource TemplatedParent}}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
IsHitTestVisible="False"
Margin="{TemplateBinding Padding}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="{Binding SelectionMode, RelativeSource={RelativeSource AncestorType=controls:MultiComboBox}, Converter={x:Static converters:ComparisionToVisibilityConverter.Instance}, ConverterParameter={x:Static SelectionMode.Single}}" />
</Grid>
<Popup
AllowsTransparency="True"
Grid.Column="0"
IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
Margin="-8"
MinWidth="{Binding ActualWidth, ElementName=PART_ToggleButton}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=PART_ToggleButton}"
PopupAnimation="Slide"
StaysOpen="True"
VerticalOffset="4"
assists:BehaviorAssist.SimulateNativeBehavior="True"
x:Name="dropDownBorder">
<Border
Background="{DynamicResource BackgroundLayoutBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}"
BorderThickness="1"
CornerRadius="4"
Effect="{DynamicResource PopupShadow}"
Margin="8"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<!-- 用于 TextBox -->
<RowDefinition Height="*" />
<!-- 用于 ListBox占据剩余空间 -->
</Grid.RowDefinitions>
<TextBox
Grid.Row="0"
Margin="6,6,6,2"
Padding="4,2"
Text="{Binding FilterText, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
VerticalAlignment="Top"
Visibility="{Binding IsFilteringEnabled, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}"
assists:InputAssist.Clearable="{TemplateBinding assists:InputAssist.Clearable}"
x:Name="PART_FilterTextBox">
<assists:InputAssist.Suffix>
<controls:IconElement
Foreground="{DynamicResource TextSecondaryBrush}"
Height="16"
Margin="4,2,2,0"
Symbol="Search"
Width="16" />
</assists:InputAssist.Suffix>
</TextBox>
<ListBox
Background="{DynamicResource BackgroundFloatingBrush}"
BorderThickness="0"
DisplayMemberPath="{Binding DisplayMemberPath, RelativeSource={RelativeSource TemplatedParent}}"
Grid.Row="1"
ItemContainerStyle="{StaticResource MultiComboBoxItemStyle}"
ItemsSource="{Binding FilteredItems, RelativeSource={RelativeSource TemplatedParent}}"
SelectionMode="{Binding SelectionMode, RelativeSource={RelativeSource TemplatedParent}}"
x:Name="PART_ListBox" />
</Grid>
</Border>
</Popup>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>