Windows Phone 8 app does not contain a definition for InitializeComponent

后端 未结 6 1210
太阳男子
太阳男子 2020-12-18 04:47

I have just downloaded the 14 CTP version of Visual Studio and created a blank app for Windows Phone. I tried to open the MainPage.xaml and the designer shows u

6条回答
  •  余生分开走
    2020-12-18 05:09

    Ensure the class name on your XAML matches the class name in your code-behind. I've run into this a few times while refactoring.

    XAML Opening Tag:

    
    

    Code Behind:

    public sealed partial class Bar : UserControl
    {
        public Bar()
        {
            // This will become the error specified (does not contain definition)
            this.InitializeComponent(); 
        }
        ...
    }
    

    So Namespace.Foo would need to be Namespace.Bar here to get rid of the error. This should have the same behavior if using Page instead of UserControl.

提交回复
热议问题