WPF继承自定义窗体

一、自定义窗体基类只能有.cs文件,不能包含.xaml文件...

public class BaseWindow01: Window
{
  public Window2()
  {
    this.AllowsTransparency = true;
    this.WindowStyle = System.Windows.WindowStyle.None;
    this.ResizeMode = System.Windows.ResizeMode.NoResize;
    this.Background = null;

  }
}

 

二、继承自定义窗体的.cs文件

public class MainWindow : BaseWindow01{}

 

三、继承自定以窗体的.xaml文件里,声明xmlns:src

<src:BaseWindow01 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

              xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

                x:Class="Demo01.MainWindow"

                xmlns:src="clr-namespace:Demo01"

                Height="640"

                Width="480">

    <Grid/>

</src:BaseWindow01 >

posted @ 2011-12-20 14:54  罗虎  阅读(1206)  评论(1编辑  收藏  举报