简体   繁体   English

当前上下文中不存在“InitializeComponent”和“_FrameViews”

[英]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:错误列表:

  1. The name 'InitializeComponent' does not exist in the current context.当前上下文中不存在名称“InitializeComponent”。
  2. The name 'FrameViews' does not exist in the current context.当前上下文中不存在名称“FrameViews”。
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.

相关问题 当前上下文中不存在“ InitializeComponent” - 'InitializeComponent' does not exist in the current context 当前上下文错误中不存在InitializeComponent - InitializeComponent does not exist in the current context error 名称InitializeComponent在当前上下文中不存在 - The name InitializeComponent does not exist in the current context 当前上下文中不存在名称“InitializeComponent”(c#,xamarin) - The name 'InitializeComponent' does not exist in the current context(c#,xamarin) WPF应用程序中的当前上下文中不存在名称“InitializeComponent” - The name 'InitializeComponent' does not exist in the current context in WPF application InitializeComponent 在当前上下文中不存在,使用 Mono C# 编译器 - InitializeComponent does not exist in the current context, using Mono C# compiler 当前上下文中不存在名称“InitializeComponent” - The name 'InitializeComponent' doesn't exist in the current context c# 不包含“InitializeComponent”的定义,名称“controlName”在当前上下文中不存在 - c# does not contain a definition for "InitializeComponent" and name "controlName" does not exist in current context 创建新的XAML文件时,当前上下文中不存在名称“ InitializeComponent” - The name 'InitializeComponent' does not exist in the current context when creating new xaml file 使用Visual Studio 2015打开WPF项目后,当前上下文错误中不存在名称“ InitializeComponent” - The name 'InitializeComponent' does not exist in the current context error after opening WPF project with Visual Studio 2015
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM