c# - NavigationService 没有定义
问题描述
我希望 MainWindow.xaml 中有一个前进按钮,以便在我的历史记录中导航到正确的页面。这是我添加到我的后退按钮单击的内容:
private void BackClick(object sender, MouseButtonEventArgs e)
{
if (this.NavigationService.CanGoBack)
{
this.NavigationService.GoBack();
}
}
不断显示的错误是
'MainWindow' does not contain a definition for 'NavigationService'
据我所知,我的导入是正确的
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Navigation;
using System.ComponentModel;
解决方案
这
this.NavigationService
您的课程中不存在该属性MainWindow
。阅读文档以获取更多信息。您需要NavigationService
从Frame
或Page
访问NavigationWindow
。
推荐阅读
- javascript - 自定义波纹效果(我想在我的内联样式中使用 var)
- java - 在 Scala 中扩展 Java 抽象类
- javascript - 如何延迟屏幕更新?
- node.js - 在 macOS 上获取最新 npm 的正确方法?
- opengl - 使用 OpenGL 对具有不同图像的立方体进行纹理处理
- java - 我无法使用 java derby 和 JavaFX 构建我的 maven 项目。包 java.sql 不可见。我该如何解决这个问题?
- cuda - 如何像 python 一样编写 cuda c argmax 内核并让它解码 one-hot 矩阵?
- php - 发布多个网址
- node.js - Sequelize:即使foreignKey被删除也能创建(偏执型)
- vue.js - 在 django admin 中使用 vue.js