From 2db765f42d5666f4ee10ecdb76cdc26e0118b73f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BA=8E=E6=99=BA=E7=BA=AF?= <于智纯@LODESTAR>
Date: Sun, 21 Sep 2025 17:14:26 +0800
Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E5=86=99=E7=AA=97=E5=8F=A3=E6=A8=A1?=
=?UTF-8?q?=E7=89=88=EF=BC=8C=E6=9C=AA=E6=88=90=E5=8A=9F=E5=AE=9E=E7=8E=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DeedyDesigner/Deedy.Testing/ElegantWindow.cs | 91 +++++++++++++------
.../Deedy.Testing/MainWindow.xaml.cs | 3 +-
.../Deedy.Testing/Themes/Generic.xaml | 70 +++++++++++++-
3 files changed, 131 insertions(+), 33 deletions(-)
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 @@
-
+
+
+
+
+
+
+
+
+
+
+
+