enhance: close #1355
This commit is contained in:
1 parent
61a964f9ea
commit
624545376f
4 files changed
+20
-6
No files matched your search
@@ -5057,6 +5057,7 @@
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Height" Value="{StaticResource DefaultControlHeight}" />
|
||||
<Setter Property="hc:TitleElement.Foreground" Value="{DynamicResource TextIconBrush}" />
|
||||
<Setter Property="ShowCloseButton" Value="{Binding Path=(hc:TagContainer.ShowCloseButton), RelativeSource={RelativeSource AncestorType=hc:TagContainer}}" />
|
||||
<Setter Property="FocusVisualStyle">
|
||||
<Setter.Value>
|
||||
<Style>
|
||||
@@ -5084,13 +5085,13 @@
|
||||
<ContentPresenter TextElement.Foreground="{Binding Path=(hc:TitleElement.Foreground),RelativeSource={RelativeSource TemplatedParent}}" ContentSource="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||
</Border>
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}" Grid.Column="1" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
<Button Focusable="False" Name="ButtonClose" Visibility="{TemplateBinding ShowCloseButton,Converter={StaticResource Boolean2VisibilityConverter}}" Command="interactivity:ControlCommands.Close" Margin="0,0,6,0" Width="16" Grid.Column="2" Style="{StaticResource ButtonIcon}" Padding="0,11" hc:IconElement.Geometry="{StaticResource DeleteGeometry}" Foreground="{TemplateBinding Foreground}" />
|
||||
<Button Focusable="False" Name="ButtonClose" Padding="0" BorderThickness="0" hc:IconElement.Width="8" Visibility="{TemplateBinding ShowCloseButton,Converter={StaticResource Boolean2VisibilityConverter}}" Command="interactivity:ControlCommands.Close" Margin="0,0,6,0" Width="16" Grid.Column="2" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource DeleteGeometry}" Foreground="{TemplateBinding Foreground}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
|
||||
<Setter Property="hc:IconElement.Geometry" Value="{StaticResource DeleteFillCircleGeometry}" TargetName="ButtonClose" />
|
||||
<Setter Property="Padding" Value="0,6" TargetName="ButtonClose" />
|
||||
<Setter Property="hc:IconElement.Width" Value="14" TargetName="ButtonClose" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
@@ -1,17 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools.Extension;
|
||||
|
||||
namespace HandyControl.Controls;
|
||||
|
||||
public class TagContainer : ItemsControl
|
||||
{
|
||||
public static readonly DependencyProperty ShowCloseButtonProperty = DependencyProperty.RegisterAttached(
|
||||
"ShowCloseButton", typeof(bool), typeof(TagContainer), new FrameworkPropertyMetadata(ValueBoxes.TrueBox,
|
||||
FrameworkPropertyMetadataOptions.Inherits));
|
||||
|
||||
public TagContainer()
|
||||
{
|
||||
AddHandler(Controls.Tag.ClosedEvent, new RoutedEventHandler(Tag_OnClosed));
|
||||
}
|
||||
|
||||
public static void SetShowCloseButton(DependencyObject element, bool value)
|
||||
=> element.SetValue(ShowCloseButtonProperty, ValueBoxes.BooleanBox(value));
|
||||
|
||||
public static bool GetShowCloseButton(DependencyObject element)
|
||||
=> (bool) element.GetValue(ShowCloseButtonProperty);
|
||||
|
||||
private void Tag_OnClosed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (e.OriginalSource is Tag tag)
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<Setter Property="VerticalAlignment" Value="Center"/>
|
||||
<Setter Property="Height" Value="{StaticResource DefaultControlHeight}"/>
|
||||
<Setter Property="hc:TitleElement.Foreground" Value="{DynamicResource TextIconBrush}"/>
|
||||
<Setter Property="ShowCloseButton" Value="{Binding Path=(hc:TagContainer.ShowCloseButton), RelativeSource={RelativeSource AncestorType=hc:TagContainer}}" />
|
||||
<Setter Property="FocusVisualStyle">
|
||||
<Setter.Value>
|
||||
<Style>
|
||||
@@ -40,13 +41,13 @@
|
||||
<ContentPresenter TextElement.Foreground="{Binding Path=(hc:TitleElement.Foreground),RelativeSource={RelativeSource TemplatedParent}}" ContentSource="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
|
||||
</Border>
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}" Grid.Column="1" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
|
||||
<Button Focusable="False" Name="ButtonClose" Visibility="{TemplateBinding ShowCloseButton,Converter={StaticResource Boolean2VisibilityConverter}}" Command="interactivity:ControlCommands.Close" Margin="0,0,6,0" Width="16" Grid.Column="2" Style="{StaticResource ButtonIcon}" Padding="0,11" hc:IconElement.Geometry="{StaticResource DeleteGeometry}" Foreground="{TemplateBinding Foreground}"/>
|
||||
<Button Focusable="False" Name="ButtonClose" Padding="0" BorderThickness="0" hc:IconElement.Width="8" Visibility="{TemplateBinding ShowCloseButton,Converter={StaticResource Boolean2VisibilityConverter}}" Command="interactivity:ControlCommands.Close" Margin="0,0,6,0" Width="16" Grid.Column="2" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource DeleteGeometry}" Foreground="{TemplateBinding Foreground}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
|
||||
<Setter Property="hc:IconElement.Geometry" Value="{StaticResource DeleteFillCircleGeometry}" TargetName="ButtonClose"/>
|
||||
<Setter Property="Padding" Value="0,6" TargetName="ButtonClose"/>
|
||||
<Setter Property="hc:IconElement.Width" Value="14" TargetName="ButtonClose"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
@@ -5057,6 +5057,7 @@
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
<Setter Property="Height" Value="{StaticResource DefaultControlHeight}" />
|
||||
<Setter Property="hc:TitleElement.Foreground" Value="{DynamicResource TextIconBrush}" />
|
||||
<Setter Property="ShowCloseButton" Value="{Binding Path=(hc:TagContainer.ShowCloseButton), RelativeSource={RelativeSource AncestorType=hc:TagContainer}}" />
|
||||
<Setter Property="FocusVisualStyle">
|
||||
<Setter.Value>
|
||||
<Style>
|
||||
@@ -5084,13 +5085,13 @@
|
||||
<ContentPresenter TextElement.Foreground="{Binding Path=(hc:TitleElement.Foreground),RelativeSource={RelativeSource TemplatedParent}}" ContentSource="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||
</Border>
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}" Grid.Column="1" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
|
||||
<Button Focusable="False" Name="ButtonClose" Visibility="{TemplateBinding ShowCloseButton,Converter={StaticResource Boolean2VisibilityConverter}}" Command="interactivity:ControlCommands.Close" Margin="0,0,6,0" Width="16" Grid.Column="2" Style="{StaticResource ButtonIcon}" Padding="0,11" hc:IconElement.Geometry="{StaticResource DeleteGeometry}" Foreground="{TemplateBinding Foreground}" />
|
||||
<Button Focusable="False" Name="ButtonClose" Padding="0" BorderThickness="0" hc:IconElement.Width="8" Visibility="{TemplateBinding ShowCloseButton,Converter={StaticResource Boolean2VisibilityConverter}}" Command="interactivity:ControlCommands.Close" Margin="0,0,6,0" Width="16" Grid.Column="2" Style="{StaticResource ButtonIcon}" hc:IconElement.Geometry="{StaticResource DeleteGeometry}" Foreground="{TemplateBinding Foreground}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
|
||||
<Setter Property="hc:IconElement.Geometry" Value="{StaticResource DeleteFillCircleGeometry}" TargetName="ButtonClose" />
|
||||
<Setter Property="Padding" Value="0,6" TargetName="ButtonClose" />
|
||||
<Setter Property="hc:IconElement.Width" Value="14" TargetName="ButtonClose" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
Reference in new issue
Block a user