c# - 当前上下文中不存在名称 'InitializeComponent'(c#,xamarin)

标签 c# xaml xamarin

我刚刚下载了 Visual Studio 并创建了一个新的 Xamarin.Forms 项目。但是,在使用自动生成的代码构建应用程序时,我在 MainPage.xaml 的代码隐藏中遇到了以下错误:The name 'InitializeComponent' does not exist in the current context我在互联网上查找了解决方案,但没有找到适合我的解决方案。
我试过的:

  • 在 MainPage.xaml 的属性中更改自定义工具(事先为空)
  • 我检查了命名空间是否匹配(它们匹配)
  • 我尝试保存所有文件

  • 这是自动生成的代码的图像,我没有编辑:
    MainPage.xaml and MainPage.xaml.cs

    最佳答案

    我在这里和那里都遇到过这个问题 InitializeComponent以及许多其他类和方法“在当前上下文中不存在”。不确定潜在的问题,但如果它和我遇到的一样,我卸载并重新加载所有项目。这可以通过右键单击解决方案资源管理器中的项目,单击卸载,再次右键单击并点击重新加载来完成。

    关于c# - 当前上下文中不存在名称 'InitializeComponent'(c#,xamarin),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50631828/

    相关文章:

    c# - 我们可以继承单例类吗?

    c# - 在我需要基于 XAML 控件进行计算的情况下,使用 MVVM 与控件交互的正确设计是什么?

    WPF DataGrid - 使用复选框隐藏列

    wpf - HierarchicalDataTemplate 和 TreeView 绑定(bind)编译错误

    android - 无法在 Xamarin Studio 中加载 Main.axml

    xamarin - 添加对 Xamarin.Forms 的项目引用

    java - Xamarin Binding Jar 给出错误 : does not implement inherited abstract member AsyncTask. DoInBackground(params Object[])

    c# - 优化 LINQ 表达式

    c# - 解决遗传交叉问题的算法

    c# - 由于 Intellisense 错误而无法发布