WPF error message: Partial declaration must not specify different base classes
来源:互联网 发布:编程单引号怎么打出来 编辑:程序博客网 时间:2024/05/22 06:46
WPF error message: Partial declaration must not specify different base classes
Why do I have this error message for a UserControl:
Partial declaration of MyNamespace.MyUserControl must not specify different base classes
Just because I inherited from another UserControl class I created in another namespace whereas this other namespace is referenced in the XAML as
xmlns:my="clr-namespace:ReferedNamespace;assembly=ReferedNamespace"
1 Answer
Hi, Little to go on here, but this usually happens when the code behind and the xaml file do not inherit from the same base class.
Since we do not have all the details concerning your problem, I'll create a situation that will cause the same exception to be thrown, this might help you understand your problem.
As an example, just create new WPF application using Visual Studio, The XAML might look something like this:
<Window x:Class="WpfApplication1.MainWindow" .....>
The code behind would then contain something like this:
public partial class MainWindow : Window
{
//Code here
}
Note the 'partial' modifier here. It means this class (MainWindow) might not be defined in a single file but spread out across multiple files, in this case the XAML (.xaml.cs) and the CS (.cs) files.
Now add a new UserControl to the solution. It will be named UserControl1.
Without making any changes to the XAML, change the code behind for the MainWindow:
public partial class MainWindow : UserControl1
{
//Code here
}
Now you'll get the exception you questioned about.
Look for something like this in your code, if you still can't find a solution, please provide more code.
- WPF error message: Partial declaration must not specify different base classes
- [Compile Error] Classes must not be nested
- “Internal Build Error” or “Classes Must Not Be Nested” error
- checking host system type... configure: error: can not guess host type; you must specify one
- Render partial from different folder (not shared)
- Actionscript Error: declaration must be contained within the <Declarations> tag, since it is not ass
- error C2310: catch handlers must specify one type
- Partial Classes and Methods
- partial classes(局部类型)
- C#Partial Classes
- Error: The input doesn't contain any classes. Did you specify the proper '-injars' options?
- 代码调试:error: multiple types in one declaration error: declaration does not declare anything [-fpermi
- error C2371: 'int8_t' : redefinition; different basic types;see declaration of 'int8_t'
- virtual base classes
- 15.4. Abstract Base Classes
- cramfsck: superblock magic not found,mount: you must specify the filesystem type
- error: declaration may not appear after executable statement in block
- error: declaration may not appear after executable statement in block
- IP报文结构浅析
- 创建提示对话框
- 赛灵思宣布收购 AUTOESL
- VC/MFC 不同进程间的消息通信与数据(字符串)发送
- ABAP概述
- WPF error message: Partial declaration must not specify different base classes
- SSO单点登录解决方案[转载]
- 怎样为人处事的原则和方法
- 揭开正则表达式的神秘面
- 在线程中控制进度条
- 续——冯大辉谈技术性创业团队的技术选型
- 新年新发现
- 抓取页面
- ubuntu 创建桌面快捷方式