【发布时间】:2010-10-20 20:50:59
【问题描述】:
我遇到了 WPF 中的控件继承问题。我创建了一个名为 BaseUserControl 的用户控件。我希望这个控件成为其他 WPF userControls 的基本控件。所以我写了另一个名为 FirstComponent 的 UserControl。在下一步中,我更改了此代码
FirstComponent : UserControl
到这里
FirstComponent : BaseControl
但是在编译过程中我得到了这个错误
Partial declarations of 'controlinheritance.componenets.FirstComponent' must not specify different base classes
我应该怎么做才能让 FirstComponent 从 BaseControl 派生?
编辑 感谢 abhishek 的回答,我设法继承了 controls 。但是我还有一个问题。在基类中,我指定了一个属性 public Grid _MainGrid { get;放; }。现在我想在我的派生类中创建这个网格的一个实例。所以我使用了这段代码 但是我得到一个错误属性'_MainGrid'没有值。第 8 行位置 36。
【问题讨论】:
标签: wpf inheritance user-controls wpf-controls