2025-09-04 22:39:00 +08:00
|
|
|
<ResourceDictionary
|
2025-08-20 12:10:35 +08:00
|
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
2026-01-02 17:30:41 +08:00
|
|
|
xmlns:assists="clr-namespace:Melskin.Assists"
|
|
|
|
|
xmlns:controls="clr-namespace:Melskin.Controls"
|
|
|
|
|
xmlns:converters="clr-namespace:Melskin.Converters"
|
|
|
|
|
xmlns:internal="clr-namespace:Melskin.Converters.Internal"
|
2026-01-02 17:30:30 +08:00
|
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
2025-08-20 12:10:35 +08:00
|
|
|
|
2025-09-04 22:39:00 +08:00
|
|
|
<ResourceDictionary.MergedDictionaries>
|
2026-01-02 17:30:41 +08:00
|
|
|
<ResourceDictionary Source="/Melskin;component/Themes/Animations.xaml" />
|
2025-09-04 22:39:00 +08:00
|
|
|
</ResourceDictionary.MergedDictionaries>
|
2025-09-08 19:49:09 +08:00
|
|
|
|
|
|
|
|
|
2026-01-02 17:30:30 +08:00
|
|
|
<Style TargetType="ListBox" x:Key="DefaultCascaderPanelStyle">
|
2025-08-20 12:10:35 +08:00
|
|
|
<!--<Setter Property="ItemContainerStyle" Value="{DynamicResource DefaultCascaderListBoxItemStyle}" />-->
|
|
|
|
|
<Setter Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
|
|
|
|
|
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
|
|
|
|
<Setter Property="BorderThickness" Value="1" />
|
|
|
|
|
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
|
|
|
|
<Setter Property="FontSize" Value="14" />
|
|
|
|
|
<Setter Property="Padding" Value="10,4" />
|
|
|
|
|
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
2025-10-10 11:19:58 +08:00
|
|
|
<!-- <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto" /> -->
|
2025-08-20 12:10:35 +08:00
|
|
|
<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="VerticalContentAlignment" Value="Center" />
|
|
|
|
|
<Setter Property="AlternationCount" Value="{Binding RelativeSource={RelativeSource Self}, Path=Items.Count}" />
|
|
|
|
|
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
|
|
|
|
|
<Setter Property="ItemTemplate">
|
|
|
|
|
<Setter.Value>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<Grid>
|
|
|
|
|
<Grid.ColumnDefinitions>
|
|
|
|
|
<ColumnDefinition Width="*" />
|
|
|
|
|
<ColumnDefinition Width="Auto" />
|
|
|
|
|
</Grid.ColumnDefinitions>
|
|
|
|
|
|
|
|
|
|
<!-- 核心修正:使用 TextBlock 并通过 MultiBinding 设置 Text -->
|
|
|
|
|
<TextBlock Grid.Column="0" VerticalAlignment="Center">
|
|
|
|
|
<TextBlock.Text>
|
|
|
|
|
<MultiBinding Converter="{x:Static internal:PropertyValueConverter.Instance}">
|
|
|
|
|
<!-- 第一个绑定:当前的数据项 -->
|
|
|
|
|
<Binding Path="." />
|
|
|
|
|
<!-- 第二个绑定:从祖先 Cascader 获取 DisplayMemberPath -->
|
2025-09-06 00:36:23 +08:00
|
|
|
<Binding Path="DisplayMemberPath" RelativeSource="{RelativeSource AncestorType=controls:Cascader}" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</MultiBinding>
|
|
|
|
|
</TextBlock.Text>
|
|
|
|
|
</TextBlock>
|
2025-09-08 19:49:09 +08:00
|
|
|
<controls:IconElement
|
2026-01-02 17:30:30 +08:00
|
|
|
Foreground="{DynamicResource TextPrimaryBrush}"
|
2025-08-20 12:10:35 +08:00
|
|
|
Grid.Column="1"
|
|
|
|
|
Height="8"
|
2025-09-08 19:49:09 +08:00
|
|
|
Symbol="KeyboardArrowRight"
|
2026-01-02 17:30:30 +08:00
|
|
|
Visibility="Hidden"
|
|
|
|
|
Width="8"
|
|
|
|
|
x:Name="Arrow" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</Grid>
|
|
|
|
|
<DataTemplate.Triggers>
|
|
|
|
|
<DataTrigger Value="True">
|
|
|
|
|
<DataTrigger.Binding>
|
|
|
|
|
<MultiBinding Converter="{x:Static internal:HasChildrenMultiConverter.Instance}">
|
|
|
|
|
<Binding Path="." />
|
2025-09-06 00:36:23 +08:00
|
|
|
<Binding Path="SubmenuMemberPath" RelativeSource="{RelativeSource AncestorType=controls:Cascader}" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</MultiBinding>
|
|
|
|
|
</DataTrigger.Binding>
|
2026-01-02 17:30:30 +08:00
|
|
|
<Setter Property="Visibility" TargetName="Arrow" Value="Visible" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</DataTrigger>
|
|
|
|
|
</DataTemplate.Triggers>
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
<Setter Property="Template">
|
|
|
|
|
<Setter.Value>
|
|
|
|
|
<ControlTemplate TargetType="{x:Type ListBox}">
|
|
|
|
|
<Border
|
|
|
|
|
Background="{TemplateBinding Background}"
|
|
|
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
|
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
|
|
|
|
CornerRadius="4"
|
2026-01-02 17:30:30 +08:00
|
|
|
SnapsToDevicePixels="true"
|
|
|
|
|
x:Name="Bd">
|
2025-08-20 12:10:35 +08:00
|
|
|
<ScrollViewer Focusable="false">
|
|
|
|
|
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
|
|
|
|
</ScrollViewer>
|
|
|
|
|
</Border>
|
|
|
|
|
<ControlTemplate.Triggers>
|
|
|
|
|
<Trigger Property="IsEnabled" Value="false">
|
2026-01-02 17:30:30 +08:00
|
|
|
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</Trigger>
|
|
|
|
|
<MultiTrigger>
|
|
|
|
|
<MultiTrigger.Conditions>
|
|
|
|
|
<Condition Property="IsGrouping" Value="true" />
|
|
|
|
|
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false" />
|
|
|
|
|
</MultiTrigger.Conditions>
|
|
|
|
|
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
|
|
|
|
|
</MultiTrigger>
|
|
|
|
|
</ControlTemplate.Triggers>
|
|
|
|
|
</ControlTemplate>
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
</Style>
|
|
|
|
|
|
2025-09-06 00:36:23 +08:00
|
|
|
<Style TargetType="{x:Type controls:Cascader}">
|
2025-08-20 12:10:35 +08:00
|
|
|
<Setter Property="BorderThickness" Value="1" />
|
|
|
|
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
|
|
|
|
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
|
2025-12-23 21:35:54 +08:00
|
|
|
<Setter Property="BorderBrush" Value="Transparent" />
|
2025-08-20 12:10:35 +08:00
|
|
|
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
|
2025-12-23 21:35:54 +08:00
|
|
|
<Setter Property="Padding" Value="10,6" />
|
2025-09-08 19:49:09 +08:00
|
|
|
<Setter Property="FontSize" Value="14" />
|
2025-08-20 12:10:35 +08:00
|
|
|
<Setter Property="VerticalAlignment" Value="Center" />
|
|
|
|
|
<Setter Property="assists:InputAssist.Clearable" Value="True" />
|
2025-12-23 21:35:54 +08:00
|
|
|
<Setter Property="assists:InputAssist.PlaceholderText" Value="请选择..." />
|
2025-08-20 12:10:35 +08:00
|
|
|
<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="PanelStyle" Value="{StaticResource DefaultCascaderPanelStyle}" />
|
|
|
|
|
<Setter Property="Template">
|
|
|
|
|
<Setter.Value>
|
2025-09-06 00:36:23 +08:00
|
|
|
<ControlTemplate TargetType="{x:Type controls:Cascader}">
|
2026-01-02 17:30:30 +08:00
|
|
|
<Grid SnapsToDevicePixels="true" x:Name="templateRoot">
|
2025-08-20 12:10:35 +08:00
|
|
|
<ToggleButton
|
|
|
|
|
Background="{TemplateBinding Background}"
|
|
|
|
|
BorderBrush="{TemplateBinding BorderBrush}"
|
|
|
|
|
BorderThickness="{TemplateBinding BorderThickness}"
|
2025-09-08 19:49:09 +08:00
|
|
|
IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
2026-01-02 17:30:30 +08:00
|
|
|
Style="{DynamicResource ComboBoxToggleButton}"
|
|
|
|
|
x:Name="PART_ToggleButton" />
|
2025-09-08 19:49:09 +08:00
|
|
|
<TextBlock
|
2025-12-23 21:35:54 +08:00
|
|
|
IsHitTestVisible="False"
|
2026-01-02 17:30:30 +08:00
|
|
|
Margin="{TemplateBinding Padding}"
|
2025-09-08 19:49:09 +08:00
|
|
|
Text="{Binding SelectedText, RelativeSource={RelativeSource AncestorType=controls:Cascader}}"
|
2026-01-02 17:30:30 +08:00
|
|
|
TextTrimming="CharacterEllipsis"
|
|
|
|
|
VerticalAlignment="Center" />
|
2025-08-20 12:10:35 +08:00
|
|
|
<TextBlock
|
2026-01-02 17:30:30 +08:00
|
|
|
Foreground="{DynamicResource TextPlaceholderBrush}"
|
|
|
|
|
IsHitTestVisible="False"
|
2025-10-10 11:19:58 +08:00
|
|
|
Margin="{TemplateBinding Padding}"
|
2025-12-23 21:35:54 +08:00
|
|
|
Padding="3"
|
2026-01-02 17:30:30 +08:00
|
|
|
Text="{Binding Path=(assists:InputAssist.PlaceholderText), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=controls:Cascader}}"
|
2025-10-10 11:19:58 +08:00
|
|
|
VerticalAlignment="Center"
|
2026-01-02 17:30:30 +08:00
|
|
|
x:Name="Placeholder">
|
2025-08-20 12:10:35 +08:00
|
|
|
<TextBlock.Style>
|
|
|
|
|
<Style TargetType="TextBlock">
|
|
|
|
|
<Setter Property="Visibility" Value="Collapsed" />
|
|
|
|
|
<Style.Triggers>
|
2025-09-06 00:36:23 +08:00
|
|
|
<DataTrigger Binding="{Binding SelectedText, RelativeSource={RelativeSource AncestorType=controls:Cascader}}" Value="">
|
2025-08-20 12:10:35 +08:00
|
|
|
<Setter Property="Visibility" Value="Visible" />
|
|
|
|
|
</DataTrigger>
|
|
|
|
|
</Style.Triggers>
|
|
|
|
|
</Style>
|
|
|
|
|
</TextBlock.Style>
|
|
|
|
|
</TextBlock>
|
|
|
|
|
<Popup
|
|
|
|
|
AllowsTransparency="True"
|
|
|
|
|
IsOpen="{Binding IsChecked, ElementName=PART_ToggleButton}"
|
2026-01-02 17:30:30 +08:00
|
|
|
Margin="-8"
|
2025-08-20 12:10:35 +08:00
|
|
|
Placement="Bottom"
|
|
|
|
|
PlacementTarget="{Binding ElementName=PART_ToggleButton}"
|
|
|
|
|
PopupAnimation="Slide"
|
2026-01-02 17:30:30 +08:00
|
|
|
StaysOpen="True"
|
|
|
|
|
assists:BehaviorAssist.SimulateNativeBehavior="True"
|
|
|
|
|
x:Name="PART_Popup">
|
2025-08-20 12:10:35 +08:00
|
|
|
<Border
|
2025-09-06 00:36:23 +08:00
|
|
|
Background="{DynamicResource BackgroundFloatingBrush}"
|
2025-08-20 12:10:35 +08:00
|
|
|
BorderBrush="{DynamicResource BorderNormalBrush}"
|
|
|
|
|
BorderThickness="1"
|
|
|
|
|
CornerRadius="4"
|
|
|
|
|
Effect="{DynamicResource PopupShadow}"
|
2026-01-02 17:30:30 +08:00
|
|
|
Margin="8"
|
|
|
|
|
MaxHeight="300"
|
|
|
|
|
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
|
|
|
|
|
SnapsToDevicePixels="True"
|
|
|
|
|
x:Name="PART_Border">
|
2025-08-20 12:10:35 +08:00
|
|
|
<Grid>
|
|
|
|
|
<Grid.RowDefinitions>
|
|
|
|
|
<RowDefinition Height="Auto" />
|
|
|
|
|
<RowDefinition Height="*" />
|
|
|
|
|
</Grid.RowDefinitions>
|
|
|
|
|
<TextBox
|
|
|
|
|
Grid.Row="0"
|
|
|
|
|
Margin="4"
|
2026-01-02 17:30:30 +08:00
|
|
|
Text="{Binding SearchText, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
|
|
|
|
|
x:Name="PART_SearchBox">
|
2025-08-20 12:10:35 +08:00
|
|
|
<assists:InputAssist.Suffix>
|
2025-09-08 19:49:09 +08:00
|
|
|
<controls:IconElement
|
2026-01-02 17:30:30 +08:00
|
|
|
Foreground="{DynamicResource TextSecondaryBrush}"
|
2025-09-08 19:49:09 +08:00
|
|
|
Height="16"
|
|
|
|
|
Margin="4,2,2,0"
|
2026-01-02 17:30:30 +08:00
|
|
|
Symbol="Search"
|
|
|
|
|
Width="16" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</assists:InputAssist.Suffix>
|
|
|
|
|
</TextBox>
|
|
|
|
|
<Grid Grid.Row="1">
|
|
|
|
|
<ScrollViewer
|
|
|
|
|
HorizontalScrollBarVisibility="Auto"
|
2026-01-02 17:30:30 +08:00
|
|
|
VerticalScrollBarVisibility="Disabled"
|
|
|
|
|
x:Name="PART_CascadingView">
|
2025-08-20 12:10:35 +08:00
|
|
|
<ContentPresenter Content="{TemplateBinding CascadingPanel}" />
|
|
|
|
|
</ScrollViewer>
|
|
|
|
|
|
|
|
|
|
<!-- 改造搜索结果列表 -->
|
|
|
|
|
<ListBox
|
|
|
|
|
HorizontalContentAlignment="Stretch"
|
|
|
|
|
ItemsSource="{Binding FilteredItemsSource, RelativeSource={RelativeSource TemplatedParent}}"
|
|
|
|
|
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
2026-01-02 17:30:30 +08:00
|
|
|
Visibility="Collapsed"
|
|
|
|
|
x:Name="PART_SearchResultsView">
|
2025-08-20 12:10:35 +08:00
|
|
|
<ListBox.ItemTemplate>
|
|
|
|
|
<DataTemplate>
|
|
|
|
|
<!-- 使用一个完全透明的按钮来承载内容和命令 -->
|
|
|
|
|
<Button
|
2025-12-23 21:35:54 +08:00
|
|
|
Command="{Binding RelativeSource={RelativeSource AncestorType=controls:Cascader}, Path=SelectSearchResultCommand}"
|
2026-01-02 17:30:30 +08:00
|
|
|
CommandParameter="{Binding}"
|
|
|
|
|
HorizontalContentAlignment="Stretch"
|
|
|
|
|
Padding="4,2">
|
2025-08-20 12:10:35 +08:00
|
|
|
<Button.Template>
|
|
|
|
|
<ControlTemplate TargetType="Button">
|
|
|
|
|
<Border
|
2026-01-02 17:30:30 +08:00
|
|
|
Background="Transparent"
|
2025-08-20 12:10:35 +08:00
|
|
|
Padding="{TemplateBinding Padding}"
|
2026-01-02 17:30:30 +08:00
|
|
|
x:Name="Bd">
|
2025-08-20 12:10:35 +08:00
|
|
|
<ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center" />
|
|
|
|
|
</Border>
|
|
|
|
|
<ControlTemplate.Triggers>
|
|
|
|
|
<Trigger Property="IsMouseOver" Value="True">
|
2026-01-02 17:30:30 +08:00
|
|
|
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</Trigger>
|
|
|
|
|
</ControlTemplate.Triggers>
|
|
|
|
|
</ControlTemplate>
|
|
|
|
|
</Button.Template>
|
2025-10-10 11:19:58 +08:00
|
|
|
<!-- 按钮的内容就是之前定义的文本 -->
|
2025-08-20 12:10:35 +08:00
|
|
|
<TextBlock
|
|
|
|
|
Text="{Binding DisplayText}"
|
|
|
|
|
TextTrimming="CharacterEllipsis"
|
|
|
|
|
ToolTip="{Binding DisplayText}" />
|
|
|
|
|
</Button>
|
|
|
|
|
</DataTemplate>
|
|
|
|
|
</ListBox.ItemTemplate>
|
|
|
|
|
</ListBox>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Grid>
|
2025-12-23 21:35:54 +08:00
|
|
|
|
2025-08-20 12:10:35 +08:00
|
|
|
</Border>
|
|
|
|
|
</Popup>
|
|
|
|
|
</Grid>
|
|
|
|
|
<ControlTemplate.Triggers>
|
|
|
|
|
<Trigger Property="IsMouseOver" Value="True">
|
2025-12-23 21:35:54 +08:00
|
|
|
<Setter Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
|
|
|
|
</Trigger>
|
|
|
|
|
<Trigger Property="IsFocused" Value="True">
|
|
|
|
|
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryFocusedBrush}" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</Trigger>
|
2025-12-23 21:35:54 +08:00
|
|
|
|
2025-08-20 12:10:35 +08:00
|
|
|
<Trigger Property="IsEnabled" Value="False">
|
2025-08-25 17:30:53 +08:00
|
|
|
<Setter Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
|
|
|
|
<Setter Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</Trigger>
|
|
|
|
|
<Trigger Property="IsDropDownOpen" Value="True">
|
2025-08-25 17:30:53 +08:00
|
|
|
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</Trigger>
|
|
|
|
|
<MultiDataTrigger>
|
|
|
|
|
<MultiDataTrigger.Conditions>
|
2025-09-04 22:39:00 +08:00
|
|
|
<Condition Binding="{Binding Path=SearchText, RelativeSource={RelativeSource Self}, Converter={x:Static converters:NullOrEmptyConverter.NotInstance}}" Value="True" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</MultiDataTrigger.Conditions>
|
2026-01-02 17:30:30 +08:00
|
|
|
<Setter Property="Visibility" TargetName="PART_CascadingView" Value="Collapsed" />
|
|
|
|
|
<Setter Property="Visibility" TargetName="PART_SearchResultsView" Value="Visible" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</MultiDataTrigger>
|
|
|
|
|
<Trigger Property="IsSearchable" Value="False">
|
2026-01-02 17:30:30 +08:00
|
|
|
<Setter Property="Visibility" TargetName="PART_SearchBox" Value="Collapsed" />
|
|
|
|
|
<Setter Property="Background" TargetName="PART_Border" Value="Transparent" />
|
|
|
|
|
<Setter Property="BorderThickness" TargetName="PART_Border" Value="0" />
|
2025-08-20 12:10:35 +08:00
|
|
|
</Trigger>
|
|
|
|
|
</ControlTemplate.Triggers>
|
|
|
|
|
</ControlTemplate>
|
|
|
|
|
</Setter.Value>
|
|
|
|
|
</Setter>
|
|
|
|
|
</Style>
|
|
|
|
|
</ResourceDictionary>
|