如何在C#中的WPF Modern UI中按按钮导航链接?

如何在C#中的WPF Modern UI中按按钮导航链接?,第1张

概述我使用 ModernUI.我有一个问题与按钮链接. 我试图通过Button Click事件导航,我在“Home.xaml”中的代码如下所示 private void addGameButton_Click(object sender, RoutedEventArgs e){ BBCodeBlock bs = new BBCodeBlock(); try { 我使用 ModernUI.我有一个问题与按钮和链接.

我试图通过button Click事件导航,我在“Home.xaml”中的代码如下所示

private voID addGamebutton_Click(object sender,RoutedEventArgs e){    BBCodeBlock bs = new BBCodeBlock();    try    {        bs.linkNavigator.Navigate(new Uri("pack://application:/Pages/AddGame.xaml"),null);    }    catch (Exception error)    {        ModernDialog.ShowMessage(error.Message,FirstFloor.ModernUI.Resources.NavigationFailed,MessageBoxbutton.OK);    }}

mui:链接在Mainwindows.xaml中正常工作以进行导航.但我想通过Home.xaml页面中的button导航到Home.xaml Page的AddGame.xaml.

我的文件结构如下,供参考.

所以请告诉我,我在哪里做错了?

解决方法 bs.linkNavigator.Navigate方法的第二个参数是不能为null的源.试试这个:
private voID addGamebutton_Click(object sender,RoutedEventArgs e){    BBCodeBlock bs = new BBCodeBlock();    try    {        bs.linkNavigator.Navigate(new Uri("/Pages/AddGame.xaml",UriKind.relative),this);    }    catch (Exception error)    {        ModernDialog.ShowMessage(error.Message,MessageBoxbutton.OK);    }}
总结

以上是内存溢出为你收集整理的如何在C#中的WPF Modern UI中按按钮导航链接?全部内容,希望文章能够帮你解决如何在C#中的WPF Modern UI中按按钮导航链接?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1247967.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-07
下一篇 2022-06-07

发表评论

登录后才能评论

评论列表(0条)

保存