Basewin cannot have a XAML file, it can only be a class
namespace WPFStudy
{
public class MyBaseWin : Window
{
Span class= "KWD" >public mybasewin ( int W int h string title ) {
this.WindowStartupLocation = WindowStartupLocation.CenterScreen;
this.Width = w;
this.Height = h;
this.Title = title;
this.FontSize = 50;
}
}
}
Subclass inheritance Note There are two places that need to be changed, one is a CS file of two, and the other is a XAML file
public partial class WinTest : MyBaseWin
{
public WinTest(int w,int h,String title):base(w,h,title)
{
InitializeComponent();
}
}
public partial class WinTest : WPFStudy.MyBaseWin, System.Windows.Markup.IComponentConnector {
<my:MyBaseWin x:Class="WPFStudy.WinTest"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:my="clr-namespace:WPFStudy"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
>
<Grid>
<Label Content="test"></Label>
<Button Content="测试"></Button>
</Grid>
</my:MyBaseWin>
From for notes (Wiz)
WPF inherits form controls that you design