Fixed some major issues where it wasn't possible to switch the app accent based on the current system accent.

This commit is contained in:
Daniel Clark
2021-02-09 13:10:23 +00:00
parent 085e632eb9
commit fae7721b5f
7 changed files with 21 additions and 101 deletions
@@ -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()
@@ -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;