mirror of
https://gitee.com/akwkevin/aistudio.-wpf.-diagram
synced 2026-04-02 07:06:37 +08:00
link
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -18,11 +20,48 @@ namespace AIStudio.Wpf.Mind.Controls
|
||||
/// <summary>
|
||||
/// LinkControl.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class LinkControl : UserControl
|
||||
[TemplatePart(Name = "PART_InnerHyperlink", Type = typeof(Hyperlink))]
|
||||
public class LinkControl : Control
|
||||
{
|
||||
public LinkControl()
|
||||
public static readonly DependencyProperty UrlProperty =
|
||||
DependencyProperty.Register(nameof(Url), typeof(string), typeof(LinkControl));
|
||||
|
||||
[Category("Common Properties"), Bindable(true)]
|
||||
public string Url
|
||||
{
|
||||
InitializeComponent();
|
||||
get
|
||||
{
|
||||
return GetValue(UrlProperty) as string;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetValue(UrlProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
static LinkControl()
|
||||
{
|
||||
FrameworkElement.DefaultStyleKeyProperty.OverrideMetadata(
|
||||
typeof(LinkControl),
|
||||
new FrameworkPropertyMetadata(typeof(LinkControl)));
|
||||
|
||||
}
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
base.OnApplyTemplate();
|
||||
|
||||
Hyperlink innerHyperlink = GetTemplateChild("PART_InnerHyperlink") as Hyperlink;
|
||||
if (innerHyperlink != null)
|
||||
{
|
||||
innerHyperlink.Click += new RoutedEventHandler(InnerHyperlink_Click);
|
||||
}
|
||||
}
|
||||
|
||||
void InnerHyperlink_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// 激活的是当前默认的浏览器
|
||||
Process.Start("explorer.exe", Url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user