【发布时间】:2010-02-15 10:42:53
【问题描述】:
我想为我的小应用尝试 MVC 设计。
我有一个扩展 UserControl 的普通 Csharp 类 ViewBase。这是一个 .cs 文件。
我有多个要扩展 ViewBase 的类。这些是实际的用户控件,因此它们在 .cs 文件和 .xaml 文件后面有一个代码。
但是,CSharp 告诉我,对于这些类,它们的基类“与其他部分中声明的不同”。
我想做的事有可能吗?我做错了什么?
请注意,我没有修改我的 XAML 文件,因此它们仍然使用标签。
以下是相关代码:
// This gives the error in question and ViewBase is underlined
// "Base class of LoginView differs from declared in other parts"
public partial class LoginView : ViewBase {
public LoginView(Shell shell, ControllerBase controller) : base(shell, controller) {
InitializeComponent();
}
}
// This one is a single .cs file
public abstract class ViewBase : UserControl {
public Shell Shell { get; set; }
public ControllerBase Controller { get; set; }
protected ViewBase(Shell shell, ControllerBase controller)
{
Shell = shell;
Controller = controller;
}
}
【问题讨论】:
标签: c# wpf inheritance