From ee7530b8b58f2251a2164d8e32c903fa48f74005 Mon Sep 17 00:00:00 2001 From: Daniel Clark Date: Fri, 12 Feb 2021 23:44:52 +0000 Subject: [PATCH] Added support common styling properties via NotificationFlyout --- samples/NotificationFlyoutSample/Shell.xaml | 7 ++- .../NotificationFlyoutHost.cs | 59 ++++++++++++------- .../NotificationFlyoutHost.xaml | 2 +- 3 files changed, 46 insertions(+), 22 deletions(-) diff --git a/samples/NotificationFlyoutSample/Shell.xaml b/samples/NotificationFlyoutSample/Shell.xaml index 265763a..cd14531 100644 --- a/samples/NotificationFlyoutSample/Shell.xaml +++ b/samples/NotificationFlyoutSample/Shell.xaml @@ -6,12 +6,17 @@ xmlns:muxc="using:Microsoft.UI.Xaml.Controls" IconSource="/Assets/Icon.ico" LightIconSource="/Assets/Icon-Light.ico"> + + + - + DefaultStyleKey = typeof(NotificationFlyoutHost); - internal void SetOwningFlyout(NotificationFlyout flyout) - { - BindingOperations.SetBinding(this, ContentProperty, - new Binding - { - Source = flyout, - Path = - new PropertyPath(nameof(Content)), - Mode = BindingMode.TwoWay - }); - - BindingOperations.SetBinding(this, RequestedThemeProperty, - new Binding - { - Source = flyout, - Path = new PropertyPath(nameof(RequestedTheme)), - Mode = BindingMode.TwoWay - }); - } - public UIElement Content { get => (UIElement)GetValue(ContentProperty); set => SetValue(ContentProperty, value); } + public Style FlyoutPresenterStyle + { + get => (Style)GetValue(FlyoutPresenterStyleProperty); + set => SetValue(FlyoutPresenterStyleProperty, value); + } public void HideFlyout() { if (_root == null) return; @@ -75,6 +67,33 @@ namespace NotificationFlyout.Uwp.UI.Controls }); } + internal void SetOwningFlyout(NotificationFlyout flyout) + { + BindingOperations.SetBinding(this, ContentProperty, + new Binding + { + Source = flyout, + Path = + new PropertyPath(nameof(Content)), + Mode = BindingMode.TwoWay + }); + + BindingOperations.SetBinding(this, RequestedThemeProperty, + new Binding + { + Source = flyout, + Path = new PropertyPath(nameof(RequestedTheme)), + Mode = BindingMode.TwoWay + }); + + BindingOperations.SetBinding(this, FlyoutPresenterStyleProperty, + new Binding + { + Source = flyout, + Path = new PropertyPath(nameof(FlyoutPresenterStyle)), + Mode = BindingMode.TwoWay + }); + } protected override void OnApplyTemplate() { _root = GetTemplateChild("Root") as Grid; diff --git a/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutHost.xaml b/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutHost.xaml index 76f7c61..4a683a1 100644 --- a/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutHost.xaml +++ b/src/NotificationFlyout.Uwp.UI.Controls/NotificationFlyout/NotificationFlyoutHost.xaml @@ -54,7 +54,7 @@ FromVerticalOffset="0" /> - +