diff --git a/DeedyDesigner/Deedy.Testing/ElegantWindow.cs b/DeedyDesigner/Deedy.Testing/ElegantWindow.cs index bad83bc..6420631 100644 --- a/DeedyDesigner/Deedy.Testing/ElegantWindow.cs +++ b/DeedyDesigner/Deedy.Testing/ElegantWindow.cs @@ -16,33 +16,7 @@ using System.Windows.Shapes; namespace Deedy { /// - /// 按照步骤 1a 或 1b 操作,然后执行步骤 2 以在 XAML 文件中使用此自定义控件。 - /// - /// 步骤 1a) 在当前项目中存在的 XAML 文件中使用该自定义控件。 - /// 将此 XmlNamespace 特性添加到要使用该特性的标记文件的根 - /// 元素中: - /// - /// xmlns:MyNamespace="clr-namespace:Deedy" - /// - /// - /// 步骤 1b) 在其他项目中存在的 XAML 文件中使用该自定义控件。 - /// 将此 XmlNamespace 特性添加到要使用该特性的标记文件的根 - /// 元素中: - /// - /// xmlns:MyNamespace="clr-namespace:Deedy;assembly=Deedy" - /// - /// 您还需要添加一个从 XAML 文件所在的项目到此项目的项目引用, - /// 并重新生成以避免编译错误: - /// - /// 在解决方案资源管理器中右击目标项目,然后依次单击 - /// “添加引用”->“项目”->[浏览查找并选择此项目] - /// - /// - /// 步骤 2) - /// 继续操作并在 XAML 文件中使用控件。 - /// - /// - /// + /// 带自定义标题头的简约窗口 /// [TemplatePart(Name = "PART_MinButton", Type = typeof(Button))] [TemplatePart(Name = "PART_MaxButton", Type = typeof(Button))] @@ -55,11 +29,72 @@ namespace Deedy } public ElegantWindow() : base() { - + } public override void OnApplyTemplate() { base.OnApplyTemplate(); + var close = this.GetTemplateChild("PART_CloseButton") as Button; } + /// + /// 窗口标题高度 + /// + public double HeaderHeight + { + get { return (double)GetValue(HeaderHeightProperty); } + set { SetValue(HeaderHeightProperty, value); } + } + public static readonly DependencyProperty HeaderHeightProperty = + DependencyProperty.Register("HeaderHeight", typeof(double), typeof(ElegantWindow), new PropertyMetadata(32.0)); + /// + /// 背景画刷「鼠标悬停」 + /// + public Brush HoverBackground + { + get { return (Brush)GetValue(HoverBackgroundProperty); } + set { SetValue(HoverBackgroundProperty, value); } + } + public static readonly DependencyProperty HoverBackgroundProperty = + DependencyProperty.Register("HoverBackground", typeof(Brush), typeof(ElegantWindow), new PropertyMetadata(Brushes.LightGray)); + /// + /// 前景画刷「鼠标悬停」 + /// + public Brush HoverForeground + { + get { return (Brush)GetValue(HoverForegroundProperty); } + set { SetValue(HoverForegroundProperty, value); } + } + public static readonly DependencyProperty HoverForegroundProperty = + DependencyProperty.Register("HoverForeground", typeof(Brush), typeof(ElegantWindow), new PropertyMetadata(Brushes.LightPink)); + /// + /// 窗口标题 + /// + public object Header + { + get { return (object)GetValue(HeaderProperty); } + set { SetValue(HeaderProperty, value); } + } + public static readonly DependencyProperty HeaderProperty = + DependencyProperty.Register("Header", typeof(object), typeof(ElegantWindow), new PropertyMetadata(null)); + /// + /// 标题数据模版 + /// + public DataTemplate HeaderTemplate + { + get { return (DataTemplate)GetValue(HeaderTemplateProperty); } + set { SetValue(HeaderTemplateProperty, value); } + } + public static readonly DependencyProperty HeaderTemplateProperty = + DependencyProperty.Register("HeaderTemplate", typeof(DataTemplate), typeof(ElegantWindow), new PropertyMetadata(null)); + /// + /// 窗口标题背景 + /// + public Brush TitleBackground + { + get { return (Brush)GetValue(TitleBackgroundProperty); } + set { SetValue(TitleBackgroundProperty, value); } + } + public static readonly DependencyProperty TitleBackgroundProperty = + DependencyProperty.Register("TitleBackground", typeof(Brush), typeof(ElegantWindow), new PropertyMetadata(Brushes.Silver)); } } diff --git a/DeedyDesigner/Deedy.Testing/MainWindow.xaml.cs b/DeedyDesigner/Deedy.Testing/MainWindow.xaml.cs index dc47a99..d770676 100644 --- a/DeedyDesigner/Deedy.Testing/MainWindow.xaml.cs +++ b/DeedyDesigner/Deedy.Testing/MainWindow.xaml.cs @@ -28,7 +28,8 @@ namespace Deedy private void Button_Click(object sender, RoutedEventArgs e) { - DrawerManager.ShowDrawer(this.decorator, new Border() { Background = Brushes.Red, MinWidth = 400, MinHeight = 400, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }); + //DrawerManager.ShowDrawer(this.decorator, new Border() { Background = Brushes.Red, MinWidth = 400, MinHeight = 400, HorizontalAlignment = HorizontalAlignment.Stretch, VerticalAlignment = VerticalAlignment.Stretch }); + new ElegantWindow().ShowDialog(); } } } \ No newline at end of file diff --git a/DeedyDesigner/Deedy.Testing/Themes/Generic.xaml b/DeedyDesigner/Deedy.Testing/Themes/Generic.xaml index b647568..93ab023 100644 --- a/DeedyDesigner/Deedy.Testing/Themes/Generic.xaml +++ b/DeedyDesigner/Deedy.Testing/Themes/Generic.xaml @@ -67,14 +67,76 @@ - + + + + + + + + + + + +