From 53bfd7da1755bb1e66b4a8a54caec9b0b47cb68d Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Thu, 1 Nov 2018 22:19:06 +0800
Subject: [PATCH] =?UTF-8?q?modify=20growlparent=E2=80=98s=20initialization?=
=?UTF-8?q?=20mode?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
HandyControl/Controls/Growl.cs | 15 ++++++++++++++-
HandyControlDemo/MainWindow.xaml | 2 +-
HandyControlDemo/MainWindow.xaml.cs | 10 +---------
3 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/HandyControl/Controls/Growl.cs b/HandyControl/Controls/Growl.cs
index 1da287b4..a9e911e1 100644
--- a/HandyControl/Controls/Growl.cs
+++ b/HandyControl/Controls/Growl.cs
@@ -121,6 +121,19 @@ namespace HandyControl.Controls
public static readonly DependencyProperty TypeProperty = DependencyProperty.Register(
"Type", typeof(InfoType), typeof(Growl), new PropertyMetadata(default(InfoType)));
+ public static readonly DependencyProperty GrowlParentProperty = DependencyProperty.RegisterAttached(
+ "GrowlParent", typeof(bool), typeof(Growl), new PropertyMetadata(default(bool), (o, args) =>
+ {
+ if (o is Panel panel)
+ {
+ SetGrowlPanel(panel);
+ }
+ }));
+
+ public static void SetGrowlParent(DependencyObject element, bool value) => element.SetValue(GrowlParentProperty, value);
+
+ public static bool GetGrowlParent(DependencyObject element) => (bool) element.GetValue(GrowlParentProperty);
+
public InfoType Type
{
get => (InfoType) GetValue(TypeProperty);
@@ -196,7 +209,7 @@ namespace HandyControl.Controls
/// 消息容器
///
///
- public static void SetGrowlPanel(Panel panel)
+ private static void SetGrowlPanel(Panel panel)
{
GrowlPanel = panel;
var menuItem = new MenuItem
diff --git a/HandyControlDemo/MainWindow.xaml b/HandyControlDemo/MainWindow.xaml
index 74744777..903bd4f2 100644
--- a/HandyControlDemo/MainWindow.xaml
+++ b/HandyControlDemo/MainWindow.xaml
@@ -30,7 +30,7 @@
-
+
\ No newline at end of file
diff --git a/HandyControlDemo/MainWindow.xaml.cs b/HandyControlDemo/MainWindow.xaml.cs
index c6c6e147..1287253a 100644
--- a/HandyControlDemo/MainWindow.xaml.cs
+++ b/HandyControlDemo/MainWindow.xaml.cs
@@ -1,18 +1,10 @@
-using HandyControl.Controls;
-
-namespace HandyControlDemo
+namespace HandyControlDemo
{
- ///
- /// MainWindow.xaml 的交互逻辑
- ///
public partial class MainWindow
{
public MainWindow()
{
-
InitializeComponent();
-
- Growl.SetGrowlPanel(PanelMessage);
}
}
}
\ No newline at end of file