从自定义 UserControl 类继承的 WPF UserControl 不起作用
我正在 WPF 中创建一个 UserControl,但它不是直接从 UserControl 类继承的。我的基类如下所示
public class MyUserControlBase: UserControl, IMyInterface1, IMyInterface2
{..}
现在在我的用户控件项目中,我已将用户控件类签名
从
public partial class MyUserControl: UserControl //This is by default when the project was created.
TO
public partial class MyUserControl: MyUserControlBase
更改为但它给出错误“'UI.MyUserControl'的部分声明不得指定不同的基类”。
请建议我必须更改什么才能使其运行。
i am creating a UserControl in WPF but it is not directly inherited from UserControl class. My base class is something as shown below
public class MyUserControlBase: UserControl, IMyInterface1, IMyInterface2
{..}
Now in my Usercontrol project, i have changed the usercontrol class signature
FROM
public partial class MyUserControl: UserControl //This is by default when the project was created.
TO
public partial class MyUserControl: MyUserControlBase
But it is giving error "Partial declarations of 'UI.MyUserControl' must not specify different base classes".
Please suggest what i have to change to make it run.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您还必须更改该控件在类的 XAML 部分中继承的位置。 WPF 中的继承仍然有点棘手,请参阅本教程了解如何正确实现它:http://svetoslavsavov.blogspot.com/2009/09/user-control-inheritance-in-wpf.html
You also have to change where this control inherits from in the XAML part of your class. Still inheritance in WPF is a bit tricky, see this tutorial on how to get it right: http://svetoslavsavov.blogspot.com/2009/09/user-control-inheritance-in-wpf.html