向超链接 C# 添加导航

问题描述 投票:0回答:1
c# wpf xaml
1个回答
0
投票

在您的代码隐藏中,您可以尝试订阅超链接的 RequestNavigate 事件。

// In constructor or after component initialization.
Hyperlink.RequestNavigate += Hyperlink_RequestNavigate;

Hyperlink_RequestNavigate 方法中,您可以处理导航逻辑。

private void Hyperlink_RequestNavigate(object sender, RequestNavigateEventArgs e)
    {
        // Navigate to the URL specified in the hyperlink
        Process.Start(new ProcessStartInfo(e.Uri.AbsoluteUri));
        e.Handled = true;
    }
© www.soinside.com 2019 - 2024. All rights reserved.