我有一個叫CustomPage簡單的類,它從窗口繼承WPF頁面代碼:更改基類的背後
public class CustomPage : Window
{
public string PageProperty { get; set; }
}
我想我的主窗口的代碼隱藏從CustomPage繼承如下:
public partial class MainWindow : CustomPage
{
public MainWindow()
{
InitializeComponent();
}
}
不幸,我得到以下錯誤:
Partial declarations of 'WpfApplication1.MainWindow' must not specify different base classes
我可以將x:Class設置爲「WpfApplication 1.CustomPage」在MainWindow.xaml,但隨後便出現我沒有獲得在MainWindow.xaml定義的UI元素...
您應該看到這篇文章:[在WPF中創建基本窗口類](http://weblogs.asp.net/psheriff/archive/2009/11/02/creating-a-base-window-class-in -wpf.aspx) – Habib