功能完善
This commit is contained in:
98
NeuWPF/NeoUI/Controls/Pill.xaml.cs
Normal file
98
NeuWPF/NeoUI/Controls/Pill.xaml.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace NeumUI.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// 标签
|
||||
/// </summary>
|
||||
public class Pill : ContentControl
|
||||
{
|
||||
static Pill()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(Pill), new FrameworkPropertyMetadata(typeof(Pill)));
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
this.MouseLeftButtonDown += Tag_MouseLeftButtonDown;
|
||||
}
|
||||
|
||||
#region 属性
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty HeaderProperty =
|
||||
DependencyProperty.Register(nameof(Header), typeof(object), typeof(Pill), new PropertyMetadata(default(object)));
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public object Header
|
||||
{
|
||||
get => (object)GetValue(HeaderProperty);
|
||||
set => SetValue(HeaderProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标题背景色
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty HeadBackgroundProperty =
|
||||
DependencyProperty.Register(nameof(HeadBackground), typeof(Brush), typeof(Pill), new PropertyMetadata(default(Brush)));
|
||||
|
||||
/// <summary>
|
||||
/// 标题背景色
|
||||
/// </summary>
|
||||
public Brush HeadBackground
|
||||
{
|
||||
get => (Brush)GetValue(HeadBackgroundProperty);
|
||||
set => SetValue(HeadBackgroundProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标题前景色
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty HeadForegroundProperty =
|
||||
DependencyProperty.Register(nameof(HeadForeground), typeof(Brush), typeof(Pill), new PropertyMetadata(default(Brush)));
|
||||
|
||||
/// <summary>
|
||||
/// 标题前景色
|
||||
/// </summary>
|
||||
public Brush HeadForeground
|
||||
{
|
||||
get => (Brush)GetValue(HeadForegroundProperty);
|
||||
set => SetValue(HeadForegroundProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 链接
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty UrlProperty =
|
||||
DependencyProperty.Register(nameof(Url), typeof(string), typeof(Pill), new PropertyMetadata(default(string)));
|
||||
|
||||
/// <summary>
|
||||
/// 链接
|
||||
/// </summary>
|
||||
public string Url
|
||||
{
|
||||
get => (string)GetValue(UrlProperty);
|
||||
set => SetValue(UrlProperty, value);
|
||||
}
|
||||
|
||||
#endregion 属性
|
||||
|
||||
#region 方法
|
||||
|
||||
private void Tag_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(Url))
|
||||
{
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(Url) { UseShellExecute = true });
|
||||
}
|
||||
}
|
||||
|
||||
#endregion 方法
|
||||
}
|
||||
Reference in New Issue
Block a user