c# - 单击 WPF 超链接时打开 WPF 窗体

标签 c# .net wpf xaml hyperlink

我想在单击 WPF 超链接时打开一个新的 WPF 窗体。我见过很多只打开 web url 的示例,但我想打开一个新的 WPF 表单。

最佳答案

你可以这样实现:

<Label Height="25" Margin="26,27,116,0" Name="label1" VerticalAlignment="Top">
    <Hyperlink Click="Hyperlink_Click">Click Me</Hyperlink>
</Label>

然后这样处理:

private void Hyperlink_Click(object sender, RoutedEventArgs e)
{
    Window2 form2 = new Window2();
    form2.Show();
}

关于c# - 单击 WPF 超链接时打开 WPF 窗体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5707231/

相关文章:

c# - 从 DbLinq 源代码创建 Linq to sqlite dbml

c# - Task.Run 下是否需要await/async 关键字?

c# - 在 UI 上以同步方法运行异步委托(delegate)安全吗?

c# - 将 utf8 转换为 1251

c# - 在 app.config 中使用 <rollForwardenabled ="true"/>

c# - CancellationToken 是否删除文件锁定?

c# - try catch 异常中的变量

c# - 什么时候使用 Mock v. Stub,或者什么都不用?

C# for(;;) 循环和数组

wpf - 在WPF中显示多个对话框是否安全?