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