10
我想为我的小应用尝试一个MVC设计。如何让用户控件扩展一个扩展UserControl的类?
我有一个普通的Csharp类ViewBase,它扩展了UserControl。这是一个单一的.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;
}
}
非常感谢! – 2010-02-17 20:23:01
这需要一点阐述 – 2013-05-02 13:12:09