整理代码
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
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"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
xmlns:internal="clr-namespace:Melskin.Converters.Internal">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="/Melskin;component/Themes/Animations.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
|
||||
<Style TargetType="ListBox" x:Key="DefaultCascaderPanelStyle">
|
||||
<Style x:Key="DefaultCascaderPanelStyle" TargetType="ListBox">
|
||||
<!--<Setter Property="ItemContainerStyle" Value="{DynamicResource DefaultCascaderListBoxItemStyle}" />-->
|
||||
<Setter Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
|
||||
@@ -49,13 +49,13 @@
|
||||
</TextBlock.Text>
|
||||
</TextBlock>
|
||||
<controls:IconElement
|
||||
Foreground="{DynamicResource TextPrimaryBrush}"
|
||||
x:Name="Arrow"
|
||||
Grid.Column="1"
|
||||
Height="8"
|
||||
Symbol="KeyboardArrowRight"
|
||||
Visibility="Hidden"
|
||||
Width="8"
|
||||
x:Name="Arrow" />
|
||||
Height="8"
|
||||
Foreground="{DynamicResource TextPrimaryBrush}"
|
||||
Symbol="KeyboardArrowRight"
|
||||
Visibility="Hidden" />
|
||||
</Grid>
|
||||
<DataTemplate.Triggers>
|
||||
<DataTrigger Value="True">
|
||||
@@ -65,7 +65,7 @@
|
||||
<Binding Path="SubmenuMemberPath" RelativeSource="{RelativeSource AncestorType=controls:Cascader}" />
|
||||
</MultiBinding>
|
||||
</DataTrigger.Binding>
|
||||
<Setter Property="Visibility" TargetName="Arrow" Value="Visible" />
|
||||
<Setter TargetName="Arrow" Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
@@ -75,19 +75,19 @@
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ListBox}">
|
||||
<Border
|
||||
x:Name="Bd"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="4"
|
||||
SnapsToDevicePixels="true"
|
||||
x:Name="Bd">
|
||||
SnapsToDevicePixels="true">
|
||||
<ScrollViewer Focusable="false">
|
||||
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
@@ -122,28 +122,28 @@
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type controls:Cascader}">
|
||||
<Grid SnapsToDevicePixels="true" x:Name="templateRoot">
|
||||
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
|
||||
<ToggleButton
|
||||
x:Name="PART_ToggleButton"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
IsChecked="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
|
||||
Style="{DynamicResource ComboBoxToggleButton}"
|
||||
x:Name="PART_ToggleButton" />
|
||||
Style="{DynamicResource ComboBoxToggleButton}" />
|
||||
<TextBlock
|
||||
IsHitTestVisible="False"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
Text="{Binding SelectedText, RelativeSource={RelativeSource AncestorType=controls:Cascader}}"
|
||||
TextTrimming="CharacterEllipsis"
|
||||
VerticalAlignment="Center" />
|
||||
<TextBlock
|
||||
Foreground="{DynamicResource TextPlaceholderBrush}"
|
||||
VerticalAlignment="Center"
|
||||
IsHitTestVisible="False"
|
||||
Text="{Binding SelectedText, RelativeSource={RelativeSource AncestorType=controls:Cascader}}"
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
<TextBlock
|
||||
x:Name="Placeholder"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
Padding="3"
|
||||
Text="{Binding Path=(assists:InputAssist.PlaceholderText), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=controls:Cascader}}"
|
||||
VerticalAlignment="Center"
|
||||
x:Name="Placeholder">
|
||||
Foreground="{DynamicResource TextPlaceholderBrush}"
|
||||
IsHitTestVisible="False"
|
||||
Text="{Binding Path=(assists:InputAssist.PlaceholderText), RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=controls:Cascader}}">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="TextBlock">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
@@ -156,79 +156,79 @@
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
<Popup
|
||||
x:Name="PART_Popup"
|
||||
Margin="-8"
|
||||
assists:BehaviorAssist.SimulateNativeBehavior="True"
|
||||
AllowsTransparency="True"
|
||||
IsOpen="{Binding IsChecked, ElementName=PART_ToggleButton}"
|
||||
Margin="-8"
|
||||
Placement="Bottom"
|
||||
PlacementTarget="{Binding ElementName=PART_ToggleButton}"
|
||||
PopupAnimation="Slide"
|
||||
StaysOpen="True"
|
||||
assists:BehaviorAssist.SimulateNativeBehavior="True"
|
||||
x:Name="PART_Popup">
|
||||
StaysOpen="True">
|
||||
<Border
|
||||
x:Name="PART_Border"
|
||||
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
|
||||
MaxHeight="300"
|
||||
Margin="8"
|
||||
Background="{DynamicResource BackgroundFloatingBrush}"
|
||||
BorderBrush="{DynamicResource BorderNormalBrush}"
|
||||
BorderThickness="1"
|
||||
CornerRadius="4"
|
||||
Effect="{DynamicResource PopupShadow}"
|
||||
Margin="8"
|
||||
MaxHeight="300"
|
||||
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
|
||||
SnapsToDevicePixels="True"
|
||||
x:Name="PART_Border">
|
||||
SnapsToDevicePixels="True">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox
|
||||
x:Name="PART_SearchBox"
|
||||
Grid.Row="0"
|
||||
Margin="4"
|
||||
Text="{Binding SearchText, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}"
|
||||
x:Name="PART_SearchBox">
|
||||
Text="{Binding SearchText, RelativeSource={RelativeSource TemplatedParent}, UpdateSourceTrigger=PropertyChanged}">
|
||||
<assists:InputAssist.Suffix>
|
||||
<controls:IconElement
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
Width="16"
|
||||
Height="16"
|
||||
Margin="4,2,2,0"
|
||||
Symbol="Search"
|
||||
Width="16" />
|
||||
Foreground="{DynamicResource TextSecondaryBrush}"
|
||||
Symbol="Search" />
|
||||
</assists:InputAssist.Suffix>
|
||||
</TextBox>
|
||||
<Grid Grid.Row="1">
|
||||
<ScrollViewer
|
||||
x:Name="PART_CascadingView"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
VerticalScrollBarVisibility="Disabled"
|
||||
x:Name="PART_CascadingView">
|
||||
VerticalScrollBarVisibility="Disabled">
|
||||
<ContentPresenter Content="{TemplateBinding CascadingPanel}" />
|
||||
</ScrollViewer>
|
||||
|
||||
<!-- 改造搜索结果列表 -->
|
||||
<ListBox
|
||||
x:Name="PART_SearchResultsView"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
ItemsSource="{Binding FilteredItemsSource, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
Visibility="Collapsed"
|
||||
x:Name="PART_SearchResultsView">
|
||||
Visibility="Collapsed">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<!-- 使用一个完全透明的按钮来承载内容和命令 -->
|
||||
<Button
|
||||
Command="{Binding RelativeSource={RelativeSource AncestorType=controls:Cascader}, Path=SelectSearchResultCommand}"
|
||||
CommandParameter="{Binding}"
|
||||
Padding="4,2"
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Padding="4,2">
|
||||
Command="{Binding RelativeSource={RelativeSource AncestorType=controls:Cascader}, Path=SelectSearchResultCommand}"
|
||||
CommandParameter="{Binding}">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border
|
||||
Background="Transparent"
|
||||
x:Name="Bd"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
x:Name="Bd">
|
||||
Background="Transparent">
|
||||
<ContentPresenter HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
||||
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource ControlBackgroundHoverBrush}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
@@ -267,13 +267,13 @@
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding Path=SearchText, RelativeSource={RelativeSource Self}, Converter={x:Static converters:NullOrEmptyConverter.NotInstance}}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Visibility" TargetName="PART_CascadingView" Value="Collapsed" />
|
||||
<Setter Property="Visibility" TargetName="PART_SearchResultsView" Value="Visible" />
|
||||
<Setter TargetName="PART_CascadingView" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="PART_SearchResultsView" Property="Visibility" Value="Visible" />
|
||||
</MultiDataTrigger>
|
||||
<Trigger Property="IsSearchable" Value="False">
|
||||
<Setter Property="Visibility" TargetName="PART_SearchBox" Value="Collapsed" />
|
||||
<Setter Property="Background" TargetName="PART_Border" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" TargetName="PART_Border" Value="0" />
|
||||
<Setter TargetName="PART_SearchBox" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="PART_Border" Property="Background" Value="Transparent" />
|
||||
<Setter TargetName="PART_Border" Property="BorderThickness" Value="0" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
Reference in New Issue
Block a user