diff --git a/NotificationFlyout.Sample.Uwp/NotificationFlyoutPresenter.xaml b/NotificationFlyout.Sample.Uwp/NotificationFlyoutPresenter.xaml
index 77eb5b9..adb6202 100644
--- a/NotificationFlyout.Sample.Uwp/NotificationFlyoutPresenter.xaml
+++ b/NotificationFlyout.Sample.Uwp/NotificationFlyoutPresenter.xaml
@@ -1,4 +1,4 @@
-
-
+
diff --git a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.cs b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.cs
index 7983754..8af2415 100644
--- a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.cs
+++ b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.cs
@@ -8,9 +8,9 @@ namespace NotificationFlyout.Uwp.UI.Controls
{
public class NotificationFlyoutHost : Control
{
- public static readonly DependencyProperty FlyoutPresenterProperty =
- DependencyProperty.Register(nameof(FlyoutPresenter),
- typeof(NotificationFlyoutPresenter), typeof(NotificationFlyoutHost),
+ public static readonly DependencyProperty ContentProperty =
+ DependencyProperty.Register(nameof(Content),
+ typeof(UIElement), typeof(NotificationFlyoutHost),
new PropertyMetadata(null));
private bool _isLoaded;
@@ -22,10 +22,10 @@ namespace NotificationFlyout.Uwp.UI.Controls
DefaultStyleKey = typeof(NotificationFlyoutHost);
}
- public NotificationFlyoutPresenter FlyoutPresenter
+ public UIElement Content
{
- get => (NotificationFlyoutPresenter)GetValue(FlyoutPresenterProperty);
- set => SetValue(FlyoutPresenterProperty, value);
+ get => (UIElement)GetValue(ContentProperty);
+ set => SetValue(ContentProperty, value);
}
public void HideFlyout()
@@ -59,7 +59,6 @@ namespace NotificationFlyout.Uwp.UI.Controls
protected override void OnApplyTemplate()
{
_root = GetTemplateChild("Root") as Grid;
-
if (GetTemplateChild("ContentRoot") is Grid contentRoot)
{
contentRoot.Shadow = new ThemeShadow();
diff --git a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml
index 921dc68..93db6f8 100644
--- a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml
+++ b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml
@@ -54,7 +54,7 @@
FromVerticalOffset="0" />
-
+
diff --git a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.cs b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.cs
index 438fb37..3281e06 100644
--- a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.cs
+++ b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.cs
@@ -1,71 +1,12 @@
-using System.Linq;
-using Windows.UI.Popups;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls;
namespace NotificationFlyout.Uwp.UI.Controls
{
public class NotificationFlyoutPresenter : ContentControl
{
- private NotificationFlyoutContentPresenter _contentPresenter;
-
- private bool _isColorPrevalence;
- private ElementTheme _systemTheme;
-
public NotificationFlyoutPresenter()
{
DefaultStyleKey = typeof(NotificationFlyoutPresenter);
- RegisterPropertyChangedCallback(RequestedThemeProperty, RequestedThemePropertyChanged);
- }
-
- public void UpdateFlyoutTheme(string theme, bool isColorPrevalence)
- {
- _isColorPrevalence = isColorPrevalence;
- switch (theme)
- {
- case "Dark":
- _systemTheme = ElementTheme.Dark;
- break;
- case "Light":
- _systemTheme = ElementTheme.Light;
- break;
- }
-
- UpdateThemeVisualState();
- }
-
- protected override void OnApplyTemplate()
- {
- var _contentPresenter = GetTemplateChild("ContentPresenter") as NotificationFlyoutContentPresenter;
- Loaded += OnLoaded;
- }
-
- private void OnLoaded(object sender, RoutedEventArgs args)
- {
- UpdateThemeVisualState();
- }
-
- private void RequestedThemePropertyChanged(DependencyObject sender, DependencyProperty dependencyProperty)
- {
- if (RequestedTheme == ElementTheme.Default)
- {
- _contentPresenter.SetValue(RequestedThemeProperty, _systemTheme);
- }
- else
- {
- _contentPresenter.SetValue(RequestedThemeProperty, RequestedTheme);
- }
- }
-
- private void UpdateThemeVisualState()
- {
- if (_contentPresenter == null) return;
- if (RequestedTheme == ElementTheme.Default)
- {
- _contentPresenter.SetValue(RequestedThemeProperty, _systemTheme);
- }
-
- VisualStateManager.GoToState(_contentPresenter, _isColorPrevalence ? "ColorPrevalenceTheme" : "DefaultTheme", true);
}
}
}
\ No newline at end of file
diff --git a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.xaml b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.xaml
index 6520feb..4b1b86b 100644
--- a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.xaml
+++ b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.xaml
@@ -6,10 +6,8 @@
-
diff --git a/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyout.cs b/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyout.cs
index fe991bc..a2c1035 100644
--- a/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyout.cs
+++ b/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyout.cs
@@ -5,7 +5,7 @@ using System.Windows.Media;
namespace NotificationFlyout.Wpf.UI.Controls
{
- [ContentProperty(nameof(FlyoutPresenter))]
+ [ContentProperty(nameof(Content))]
public class NotificationFlyout : DependencyObject
{
public static readonly DependencyProperty IconSourceProperty =
@@ -18,9 +18,9 @@ namespace NotificationFlyout.Wpf.UI.Controls
typeof(ImageSource), typeof(NotificationFlyout),
new PropertyMetadata(null, OnIconPropertyChanged));
- public static DependencyProperty FlyoutPresenterProperty =
- DependencyProperty.Register(nameof(FlyoutPresenter),
- typeof(NotificationFlyoutPresenter), typeof(NotificationFlyout),
+ public static DependencyProperty ContentProperty =
+ DependencyProperty.Register(nameof(Content),
+ typeof(Windows.UI.Xaml.UIElement), typeof(NotificationFlyout),
new PropertyMetadata(null, OnFlyoutPresenterPropertyChanged));
private readonly NotificationFlyoutXamlHost _xamlHost;
@@ -31,10 +31,10 @@ namespace NotificationFlyout.Wpf.UI.Controls
_xamlHost.Show();
}
- public NotificationFlyoutPresenter FlyoutPresenter
+ public Windows.UI.Xaml.UIElement Content
{
- get => (NotificationFlyoutPresenter)GetValue(FlyoutPresenterProperty);
- set => SetValue(FlyoutPresenterProperty, value);
+ get => (Windows.UI.Xaml.UIElement)GetValue(ContentProperty);
+ set => SetValue(ContentProperty, value);
}
public ImageSource IconSource
@@ -73,7 +73,7 @@ namespace NotificationFlyout.Wpf.UI.Controls
private void OnFlyoutPresenterPropertyChanged()
{
- _xamlHost.SetFlyoutPresenter(FlyoutPresenter);
+ _xamlHost.SetFlyoutContent(Content);
}
private void OnIconPropertyChanged()
diff --git a/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs b/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs
index 9229a5f..88f75ac 100644
--- a/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs
+++ b/NotificationFlyout.Wpf.UI.Controls/NotificationFlyout/NotificationFlyoutXamlHost.cs
@@ -30,17 +30,12 @@ namespace NotificationFlyout.Wpf.UI.Controls
Loaded += OnLoaded;
}
- public void SetFlyoutPresenter(NotificationFlyoutPresenter flyoutPresenter)
+ public void SetFlyoutContent(Windows.UI.Xaml.UIElement content)
{
var flyoutHost = GetFlyoutHost();
if (flyoutHost != null)
{
- flyoutHost.FlyoutPresenter = flyoutPresenter;
-
- var theme = _systemPersonalisationHelper.Theme.ToString();
- var isColorPrevalence = _systemPersonalisationHelper.IsColorPrevalence;
-
- flyoutHost.FlyoutPresenter.UpdateFlyoutTheme(theme, isColorPrevalence);
+ flyoutHost.Content = content;
}
}
@@ -111,22 +106,9 @@ namespace NotificationFlyout.Wpf.UI.Controls
private void OnThemeChanged(object sender, SystemPersonalisationChangedEventArgs args)
{
- NewMethod(args);
UpdateIcon();
}
- private void NewMethod(SystemPersonalisationChangedEventArgs args)
- {
- var flyoutHost = GetFlyoutHost();
- if (flyoutHost != null)
- {
- var theme = args.Theme.ToString();
- var isColorPrevalence = args.IsColorPrevalence;
-
- flyoutHost.FlyoutPresenter.UpdateFlyoutTheme(theme, isColorPrevalence);
- }
- }
-
private void PrepareDefaultWindow()
{
ShowInTaskbar = false;