[英]The 'InitializeComponent' and '_FrameViews' does not exist in the current context
I'm in the process of learning WPF, so in my case I have an xbap application and the code below is the code behind MainView.xaml.cs.我正在学习 WPF,所以在我的情况下,我有一个 xbap 应用程序,下面的代码是 MainView.xaml.cs 后面的代码。 Also, it was initially of a Page Type and I just changed it to UserControl recently because I need to deploy this app using ClickOnce.
此外,它最初是页面类型,我最近将其更改为 UserControl,因为我需要使用 ClickOnce 部署此应用程序。
List of errors:错误列表:
public partial class MainView : UserControl
{
public MainView()
{
InitializeComponent();
this.DataContext = MainViewModel.UniqueInstance;
MainViewModel.UniqueInstance.FrameNavigationService = _FrameViews.NavigationService;
_FrameViews.Unloaded +=new RoutedEventHandler(_FrameViews_Unloaded);
}
private void _FrameViews_Unloaded(object sender, RoutedEventArgs e)
{
_FrameViews.Content = null;
}
}
}
The InitializeComponent()
is only available in MainWindow not in MainView you need to write like that: InitializeComponent()
仅在 MainWindow 中可用,不在 MainView 中,您需要这样编写:
public partial class MainWindow : Window
and the _FrameView
doesent exist you need to declare it并且
_FrameView
不存在,您需要声明它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.