feat: support clear.
This commit is contained in:
@@ -5,65 +5,160 @@
|
||||
<!-- Add Resources Here -->
|
||||
<ControlTheme x:Key="{x:Type u:MultiComboBox}" TargetType="u:MultiComboBox">
|
||||
<Setter Property="Focusable" Value="True" />
|
||||
<Setter Property="VerticalAlignment" Value="Top"/>
|
||||
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBackground}" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource ComboBoxSelectorCornerRadius}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="HorizontalAlignment" Value="Left" />
|
||||
<Setter Property="Width" Value="300" />
|
||||
<Setter Property="MaxDropdownHeight" Value="300" />
|
||||
<Setter Property="MinHeight" Value="32" />
|
||||
<Setter Property="Padding" Value="12 4" />
|
||||
<Setter Property="BorderThickness" Value="1" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:MultiComboBox">
|
||||
<Panel>
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="Transparent"
|
||||
BorderBrush="{DynamicResource SemiGrey2}"
|
||||
BorderThickness="1">
|
||||
<Grid Name="PART_RootGrid" ColumnDefinitions="*, Auto, 32">
|
||||
<Border
|
||||
Name="{x:Static u:MultiComboBox.PART_BackgroundBorder}"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Background="Transparent" />
|
||||
<u:MultiComboBoxSelectedItemList
|
||||
Grid.Column="0"
|
||||
ItemsSource="{TemplateBinding SelectedItems}"
|
||||
RemoveCommand="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Remove}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</u:MultiComboBoxSelectedItemList>
|
||||
<PathIcon
|
||||
x:Name="DropDownGlyph"
|
||||
Grid.Column="2"
|
||||
Width="12"
|
||||
Height="12"
|
||||
Margin="0,0,10,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Data="{DynamicResource ComboBoxIcon}"
|
||||
Foreground="{DynamicResource ComboBoxIconDefaultForeground}"
|
||||
IsHitTestVisible="False"
|
||||
UseLayoutRounding="False" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<Popup
|
||||
Width="{Binding #PART_RootGrid.Bounds.Width}"
|
||||
MaxHeight="{TemplateBinding MaxDropdownHeight}"
|
||||
IsLightDismissEnabled="True"
|
||||
IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen, Mode=TwoWay}"
|
||||
PlacementTarget="PART_RootGrid">
|
||||
<Border Theme="{DynamicResource CardBorder}">
|
||||
<ScrollViewer>
|
||||
<ItemsPresenter HorizontalAlignment="Stretch" ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||
</ScrollViewer>
|
||||
<DataValidationErrors>
|
||||
<Panel>
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<Grid Name="PART_RootGrid" ColumnDefinitions="*, Auto, 32">
|
||||
<Border
|
||||
Name="{x:Static u:MultiComboBox.PART_BackgroundBorder}"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="3"
|
||||
Background="Transparent" />
|
||||
<u:MultiComboBoxSelectedItemList
|
||||
Grid.Column="0"
|
||||
VerticalAlignment="Center"
|
||||
ItemsSource="{TemplateBinding SelectedItems}"
|
||||
RemoveCommand="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Remove}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
</u:MultiComboBoxSelectedItemList>
|
||||
<Button
|
||||
Name="ClearButton"
|
||||
Grid.Column="1"
|
||||
Command="{Binding $parent[u:MultiComboBox].Clear}"
|
||||
Content="{DynamicResource IconButtonClearData}"
|
||||
IsVisible="False"
|
||||
Theme="{DynamicResource InnerIconButton}" />
|
||||
<PathIcon
|
||||
x:Name="DropDownGlyph"
|
||||
Grid.Column="2"
|
||||
Width="12"
|
||||
Height="12"
|
||||
Margin="0,0,10,0"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center"
|
||||
Data="{DynamicResource ComboBoxIcon}"
|
||||
Foreground="{DynamicResource ComboBoxIconDefaultForeground}"
|
||||
IsHitTestVisible="False"
|
||||
UseLayoutRounding="False" />
|
||||
</Grid>
|
||||
</Border>
|
||||
</Popup>
|
||||
</Panel>
|
||||
<Popup
|
||||
Width="{Binding #PART_RootGrid.Bounds.Width}"
|
||||
MaxHeight="{TemplateBinding MaxDropdownHeight}"
|
||||
IsLightDismissEnabled="True"
|
||||
IsOpen="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsDropDownOpen, Mode=TwoWay}"
|
||||
PlacementTarget="PART_RootGrid">
|
||||
<Border
|
||||
Margin="0,4"
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="{DynamicResource ComboBoxPopupBackground}"
|
||||
BorderBrush="{DynamicResource ComboBoxPopupBorderBrush}"
|
||||
BorderThickness="{DynamicResource ComboBoxPopupBorderThickness}"
|
||||
BoxShadow="{DynamicResource ComboBoxPopupBoxShadow}"
|
||||
ClipToBounds="True"
|
||||
CornerRadius="6">
|
||||
<ScrollViewer Grid.IsSharedSizeScope="True" HorizontalScrollBarVisibility="{TemplateBinding ScrollViewer.HorizontalScrollBarVisibility}" VerticalScrollBarVisibility="{TemplateBinding ScrollViewer.VerticalScrollBarVisibility}">
|
||||
<ItemsPresenter
|
||||
Name="PART_ItemsPresenter"
|
||||
Margin="{DynamicResource ComboBoxDropdownContentMargin}"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Popup>
|
||||
</Panel>
|
||||
</DataValidationErrors>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^.Large">
|
||||
<Setter Property="MinHeight" Value="{DynamicResource ComboBoxLargeHeight}" />
|
||||
</Style>
|
||||
<Style Selector="^.Small">
|
||||
<Setter Property="MinHeight" Value="{DynamicResource ComboBoxSmallHeight}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^.clearButton, ^.ClearButton">
|
||||
<Style Selector="^:pointerover:not(:selection-empty) /template/ Button#ClearButton">
|
||||
<Setter Property="IsVisible" Value="{Binding $parent[ComboBox].SelectionBoxItem, Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
|
||||
<!-- Pointerover State -->
|
||||
<Style Selector="^:pointerover">
|
||||
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorPointeroverBackground}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorPointeroverBorderBrush}" />
|
||||
</Style>
|
||||
<Style Selector="^:pointerover /template/ PathIcon#DropDownGlyph">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxIconPointeroverForeground}" />
|
||||
</Style>
|
||||
|
||||
<!-- Pressed State -->
|
||||
<Style Selector="^:pressed">
|
||||
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorPressedBackground}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorPressedBorderBrush}" />
|
||||
<Style Selector="^ /template/ PathIcon#DropDownGlyph">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxIconPressedForeground}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:dropdownopen">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorPressedBorderBrush}" />
|
||||
</Style>
|
||||
|
||||
<!-- Disabled State -->
|
||||
<Style Selector="^:disabled">
|
||||
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorDisabledBackground}" />
|
||||
<Style Selector="^ /template/ ContentControl#ContentPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDisabledForeground}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ TextBlock#PlaceholderTextBlock">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDisabledForeground}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ PathIcon#DropDownGlyph">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxIconDisabledForeground}" />
|
||||
</Style>
|
||||
</Style>
|
||||
<!-- Error State -->
|
||||
<Style Selector="^:error">
|
||||
<Style Selector="^ /template/ Border#Background">
|
||||
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsBackground}" />
|
||||
</Style>
|
||||
<Style Selector="^:pointerover /template/ Border#Background">
|
||||
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsPointerOverBackground}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</Style>
|
||||
<Style Selector="^:pressed /template/ Border#Background">
|
||||
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsPressedBackground}" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
</Style>
|
||||
<Style Selector="^:focus /template/ Border#Background">
|
||||
<Setter Property="Background" Value="{DynamicResource DataValidationErrorsSelectedBackground}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource DataValidationErrorsSelectedBorderBrush}" />
|
||||
</Style>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type u:MultiComboBoxItem}" TargetType="u:MultiComboBoxItem">
|
||||
@@ -87,26 +182,17 @@
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}">
|
||||
<Grid x:Name="RootGrid" ColumnDefinitions="Auto,*">
|
||||
<Grid
|
||||
<Grid x:Name="RootGrid" ColumnDefinitions="Auto, *">
|
||||
<PathIcon
|
||||
Name="CheckGlyph"
|
||||
Grid.Column="0"
|
||||
Margin="0,0,0,0"
|
||||
VerticalAlignment="Center">
|
||||
<Border
|
||||
x:Name="NormalRectangle"
|
||||
Width="{DynamicResource ListBoxItemCheckBoxWidth}"
|
||||
Height="{DynamicResource ListBoxItemCheckBoxHeight}"
|
||||
Background="{DynamicResource ListBoxItemCheckDefaultBackground}"
|
||||
BorderBrush="{DynamicResource ListBoxItemCheckDefaultBorderBrush}"
|
||||
BorderThickness="{DynamicResource ListBoxItemCheckBoxBorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
UseLayoutRounding="False" />
|
||||
<PathIcon
|
||||
Name="CheckGlyph"
|
||||
Width="{DynamicResource ListBoxItemCheckBoxGlyphWidth}"
|
||||
Height="{DynamicResource ListBoxItemCheckBoxGlyphHeight}"
|
||||
Foreground="{DynamicResource ListBoxItemCheckGlyphFill}" />
|
||||
</Grid>
|
||||
VerticalAlignment="Center"
|
||||
Opacity="0"
|
||||
Data="{DynamicResource ListBoxItemCheckCheckGlyph}"
|
||||
Width="{DynamicResource ListBoxItemCheckBoxGlyphWidth}"
|
||||
Height="{DynamicResource ListBoxItemCheckBoxGlyphHeight}"
|
||||
Margin="8,0"
|
||||
/>
|
||||
<ContentPresenter
|
||||
x:Name="ContentPresenter"
|
||||
Grid.Column="1"
|
||||
@@ -123,75 +209,28 @@
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
|
||||
<!-- Unchecked Pointerover State -->
|
||||
<Style Selector="^:pointerover">
|
||||
<Style Selector="^ /template/ Border#NormalRectangle">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ListBoxItemCheckPointeroverBorderBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ListBoxItemCheckPointeroverBackground}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<!-- Unchecked Pressed State -->
|
||||
<Style Selector="^:pressed">
|
||||
<Style Selector="^ /template/ Border#NormalRectangle">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ListBoxItemCheckPressedBorderBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ListBoxItemCheckPressedBackground}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<!-- Unchecked Disabled state -->
|
||||
<Style Selector="^:disabled">
|
||||
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ListBoxItemCheckDisabledForeground}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Border#NormalRectangle">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ListBoxItemCheckDefaultDisabledBorderBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ListBoxItemCheckDefaultDisabledBackground}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource ListBoxItemDisabledForeground}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ListBoxItemDisabledBackground}" />
|
||||
<Style Selector="^:selected">
|
||||
<Setter Property="Background"
|
||||
Value="{DynamicResource ListBoxItemSelectedDisabledBackground}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<Style Selector="^:selected">
|
||||
<Style Selector="^ /template/ Border#NormalRectangle">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ListBoxItemCheckCheckedDefaultBorderBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ListBoxItemCheckCheckedDefaultBackground}" />
|
||||
</Style>
|
||||
<!-- Pointerover State -->
|
||||
<Style Selector="^:pointerover">
|
||||
<Setter Property="Background" Value="{DynamicResource ListBoxItemPointeroverBackground}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ PathIcon#CheckGlyph">
|
||||
<Setter Property="Data" Value="{DynamicResource ListBoxItemCheckCheckGlyph}" />
|
||||
<Setter Property="Opacity" Value="1" />
|
||||
</Style>
|
||||
<!-- Pressed State -->
|
||||
<Style Selector="^:pressed">
|
||||
<Setter Property="Background" Value="{DynamicResource ListBoxItemPressedBackground}" />
|
||||
</Style>
|
||||
|
||||
<!-- Checked Pointerover State -->
|
||||
<Style Selector="^:pointerover">
|
||||
<Style Selector="^ /template/ Border#NormalRectangle">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ListBoxItemCheckCheckedPointeroverBorderBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ListBoxItemCheckCheckedPointeroverBackground}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<!-- Checked Pressed State -->
|
||||
<Style Selector="^:pressed">
|
||||
<Style Selector="^ /template/ Border#NormalRectangle">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ListBoxItemCheckCheckedPressedBorderBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ListBoxItemCheckCheckedPressedBackground}" />
|
||||
</Style>
|
||||
</Style>
|
||||
|
||||
<!-- Checked Disabled State -->
|
||||
<Style Selector="^:disabled">
|
||||
<Style Selector="^ /template/ ContentPresenter#ContentPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource ListBoxItemCheckDisabledForeground}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Border#NormalRectangle">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource ListBoxItemCheckCheckedDisabledBorderBrush}" />
|
||||
<Setter Property="Background" Value="{DynamicResource ListBoxItemCheckCheckedDisabledBackground}" />
|
||||
</Style>
|
||||
|
||||
<Style Selector="^ /template/ Path#CheckGlyph">
|
||||
<Setter Property="Fill" Value="{DynamicResource ListBoxItemCheckGlyphDisabledFill}" />
|
||||
</Style>
|
||||
</Style>
|
||||
<!-- Selected State -->
|
||||
<Style Selector="^:selected /template/ PathIcon#CheckGlyph">
|
||||
<Setter Property="Opacity" Value="1"></Setter>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user