InitializeComponent does not exist in the current context
来源:互联网 发布:淘宝买三角梅哪家好 编辑:程序博客网 时间:2024/05/23 11:48
You’ve made some changes to your Silverlight application and all of the sudden your MainPage.xamlwill not compile because InitializeComponent does not exist in the current context or theLinksStackPanel.Children doesn’t exist in the current context. This is a frustrating problem until you know what causes it.
The root cause of the problem is that your x:Classdirective in the “xaml” page somehow got lost or is not in sync with your code-behind file.
Did you just copy a MainPage from another project, or backed up project? Copying the MainPage.xaml and the code-behind doesn’t seem to fix the problem by itself.
First, fix the x:Class reference in your MainPage.xaml
Make sure that your x:Class is named properly and that the namespace matches that of your application! If you have already checked this then don’t worry there is one more thing that probably went wrong.
Second, fix the “Build Action” of your MainPage.xaml
This one took me several hours, and a few headaches to find. I compared a working project to the non-working one and notices that the “Build Action” of MainPage.xaml must have changed when manipulating the window. The Build Action was set to “Content”.
The Build Action should be set to “Page”
Simply highlight the MainPage.xaml in your Solution Explorer and in the properties check out the Build Action. Once you fix this, you will no longer have problems with InitializeComponent and it will fix problems with LinksStackPanel.Children not existing in the context.
You’ve made some changes to your Silverlight application and all of the sudden your MainPage.xamlwill not compile because InitializeComponent does not exist in the current context or theLinksStackPanel.Children doesn’t exist in the current context. This is a frustrating problem until you know what causes it.
The root cause of the problem is that your x:Classdirective in the “xaml” page somehow got lost or is not in sync with your code-behind file.
Did you just copy a MainPage from another project, or backed up project? Copying the MainPage.xaml and the code-behind doesn’t seem to fix the problem by itself.
First, fix the x:Class reference in your MainPage.xaml
Make sure that your x:Class is named properly and that the namespace matches that of your application! If you have already checked this then don’t worry there is one more thing that probably went wrong.
Second, fix the “Build Action” of your MainPage.xaml
This one took me several hours, and a few headaches to find. I compared a working project to the non-working one and notices that the “Build Action” of MainPage.xaml must have changed when manipulating the window. The Build Action was set to “Content”.
The Build Action should be set to “Page”
Simply highlight the MainPage.xaml in your Solution Explorer and in the properties check out the Build Action. Once you fix this, you will no longer have problems with InitializeComponent and it will fix problems with LinksStackPanel.Children not existing in the context.
- InitializeComponent does not exist in the current context
- The name 'Profile' does not exist in the current context
- The name does not exist in the current context
- HttpUtility does not exist in the current context
- 关于编写WPF UserControl时提示The name 'InitializeComponent' does not exist in the current contextr的解决!
- Error:The name 'Encoding' does not exist in the current context 解决方法
- The name 'xxx' does not exist in the current context 錯誤解決方法之一
- Unity 错误(1)——The name `xxx' does not exist in the current context
- error CS0103: The name `UnityEditor' does not exist in the current context
- 解决办法:The name 'Response' does not exist in the current context
- The name 'AccordionLayout1' does not exist in the current
- The name “LayoutAwarePage” does not exist in the namespace
- The connection does not exist.
- Dynamics CRM2015 The plug-in type does not exist in the specified assembly问题的解决方法
- react-native 警告之module does not exist in the module map or in these directories
- The type or namespace name 'Windows' does not exist in the class or namespace 'System'
- Error:The type or namespace name 'Office' does not exist in the namespace 'Microsoft' 解决方法
- error MSB4057: The target "PlatformPrepareForBuild" does not exist in the project
- Android 创建与解析XML(三)---- PULL方式
- C++笔试面试题 从网上整理的,带答案
- inittab命令格式
- VC++的Unicode编程
- 发布java 应用程序 jar
- InitializeComponent does not exist in the current context
- Linux系统32位与64位数据类型长度比较
- iOS 面试题 网络协议
- shell tr的语法
- c/c++ 程序员笔试面试题型
- c++对数组的引用
- 开发日志:ssh配置实体映射时出错could not instantiate id generator
- 程序员MM一年的工作总结
- 事件驱动模型