Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Controls/Pill.xaml.cs
ShrlAlgo 955a01f564 整理
2025-08-20 12:10:35 +08:00

98 lines
2.5 KiB
C#

using System.Windows.Input;
namespace NeoUI.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
}