delete tagpanel

This commit is contained in:
NaBian committed 2020-11-19 23:40:47 +08:00
1 parent 74a734f54d
commit 4f9b77d567
6 files changed
+71 -21

No files matched your search

@@ -6,17 +6,17 @@
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension" xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
xmlns:hc="https://handyorg.github.io/handycontrol"> xmlns:hc="https://handyorg.github.io/handycontrol">
<hc:TransitioningContentControl> <hc:TransitioningContentControl>
<hc:TagPanel AddTagButtonClick="TagPanel_OnAddTagButtonClick" Margin="32" Orientation="Horizontal" MaxWidth="400" VerticalAlignment="Center" ShowAddButton="True"> <hc:TagContainer Margin="22" Width="400" Padding="5">
<hc:Tag ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/> <hc:Tag Margin="5" ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
<hc:Tag Selectable="True" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/> <hc:Tag Margin="5" Selectable="True" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/>
<hc:Tag ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/> <hc:Tag Margin="5" ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/>
<hc:Tag Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/> <hc:Tag Margin="5" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
<hc:Tag IsSelected="True" Selectable="True" ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/> <hc:Tag Margin="5" IsSelected="True" Selectable="True" ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/>
<hc:Tag Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/> <hc:Tag Margin="5" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/>
<hc:Tag ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/> <hc:Tag Margin="5" ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=2}"/>
<hc:Tag IsSelected="True" Selectable="True" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/> <hc:Tag Margin="5" IsSelected="True" Selectable="True" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=3}"/>
<hc:Tag ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/> <hc:Tag Margin="5" ShowCloseButton="False" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=4}"/>
<hc:Tag Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/> <hc:Tag Margin="5" Content="{ex:Lang Key={x:Static langs:LangKeys.Text}, Converter={StaticResource StringRepeatConverter}, ConverterParameter=5}"/>
</hc:TagPanel> </hc:TagContainer>
</hc:TransitioningContentControl> </hc:TransitioningContentControl>
</UserControl> </UserControl>
@@ -11,14 +11,14 @@ namespace HandyControlDemo.UserControl
InitializeComponent(); InitializeComponent();
} }
private void TagPanel_OnAddTagButtonClick(object sender, EventArgs e) //private void TagPanel_OnAddTagButtonClick(object sender, EventArgs e)
{ //{
if (sender is TagPanel panel) // if (sender is TagPanel panel)
{ // {
var tag = new Tag(); // var tag = new Tag();
LangProvider.SetLang(tag, ContentProperty, LangKeys.SubTitle); // LangProvider.SetLang(tag, ContentProperty, LangKeys.SubTitle);
panel.Children.Add(tag); // panel.Children.Add(tag);
} // }
} //}
} }
} }
@@ -0,0 +1,22 @@
using System.Windows;
using System.Windows.Controls;
using HandyControl.Data;
namespace HandyControl.Controls
{
public class TagContainer : ItemsControl
{
public static readonly DependencyProperty IsToolBarVisibleProperty = DependencyProperty.Register(
"IsToolBarVisible", typeof(bool), typeof(TagContainer), new PropertyMetadata(ValueBoxes.FalseBox));
public bool IsToolBarVisible
{
get => (bool) GetValue(IsToolBarVisibleProperty);
set => SetValue(IsToolBarVisibleProperty, value);
}
protected override DependencyObject GetContainerForItemOverride() => new Tag();
protected override bool IsItemItsOwnContainerOverride(object item) => item is Tag;
}
}
@@ -72,6 +72,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\RangeThumb.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\RangeThumb.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\TwoWayRangeBase.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Slider\RangeSlider\TwoWayRangeBase.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Block\RunningBlock\RunningBlock.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Block\RunningBlock\RunningBlock.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Tag\TagContainer.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Text\SimpleText.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Text\SimpleText.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Controls\Window\GlowWindow.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Controls\Window\GlowWindow.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Collections\DateTimeRangeComparer.cs" /> <Compile Include="$(MSBuildThisFileDirectory)Collections\DateTimeRangeComparer.cs" />
@@ -77,4 +77,29 @@
<Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/> <Setter Property="Foreground" Value="{DynamicResource TextIconBrush}"/>
</Style> </Style>
<Style x:Key="TagContainerBaseStyle" TargetType="hc:TagContainer" BasedOn="{StaticResource BaseStyle}">
<Setter Property="hc:BorderElement.CornerRadius" Value="{StaticResource DefaultCornerRadius}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource TagBaseStyle}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="hc:TagContainer">
<Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}">
<hc:ScrollViewer Focusable="false">
<ItemsPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</hc:ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary> </ResourceDictionary>
@@ -8,4 +8,6 @@
<Style BasedOn="{StaticResource TagBaseStyle}" TargetType="hc:Tag"/> <Style BasedOn="{StaticResource TagBaseStyle}" TargetType="hc:Tag"/>
<Style BasedOn="{StaticResource TagContainerBaseStyle}" TargetType="hc:TagContainer"/>
</ResourceDictionary> </ResourceDictionary>