diff --git a/NotificationFlyout.Sample/NotificationFlyoutPresenter.xaml b/NotificationFlyout.Sample/NotificationFlyoutPresenter.xaml index 812e2e0..a1488a1 100644 --- a/NotificationFlyout.Sample/NotificationFlyoutPresenter.xaml +++ b/NotificationFlyout.Sample/NotificationFlyoutPresenter.xaml @@ -2,8 +2,7 @@ x:Class="NotificationFlyout.Sample.NotificationFlyoutPresenter" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" - xmlns:controls="using:NotificationFlyout.Uwp.UI.Controls" - CornerRadius="4"> + xmlns:controls="using:NotificationFlyout.Uwp.UI.Controls"> - diff --git a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.cs b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.cs index cad8da5..d4cb3f4 100644 --- a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.cs +++ b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.cs @@ -11,20 +11,13 @@ namespace NotificationFlyout.Uwp.UI.Controls typeof(NotificationFlyoutPresenter), typeof(NotificationFlyoutHost), new PropertyMetadata(null)); - public static readonly DependencyProperty TemplateSettingsProperty = - DependencyProperty.Register(nameof(TemplateSettings), - typeof(NotificationFlyoutHostTemplateSettings), typeof(NotificationFlyoutHost), - new PropertyMetadata(null)); - - private readonly NotificationFlyoutHostTemplateSettings _templateSettings; + private bool _isLoaded; + private string _placement; private Grid _root; public NotificationFlyoutHost() { DefaultStyleKey = typeof(NotificationFlyoutHost); - - _templateSettings = new NotificationFlyoutHostTemplateSettings(); - SetValue(TemplateSettingsProperty, _templateSettings); } public NotificationFlyoutPresenter FlyoutPresenter @@ -33,12 +26,6 @@ namespace NotificationFlyout.Uwp.UI.Controls set => SetValue(FlyoutPresenterProperty, value); } - public NotificationFlyoutHostTemplateSettings TemplateSettings - { - get => (NotificationFlyoutHostTemplateSettings)GetValue(TemplateSettingsProperty); - set => SetValue(TemplateSettingsProperty, value); - } - public void HideFlyout() { if (_root == null) return; @@ -46,11 +33,14 @@ namespace NotificationFlyout.Uwp.UI.Controls flyout.Hide(); } - public void SetOffset(double verticalOffset, double horizontalOffset) + public void SetFlyoutPlacement(string placement) { - if (_templateSettings == null) return; - _templateSettings.FromVerticalOffset = verticalOffset; - _templateSettings.FromHorizontalOffset = horizontalOffset; + if (!_isLoaded) + { + _placement = placement; + } + + VisualStateManager.GoToState(this, placement, true); } public void ShowFlyout(FlyoutPlacementMode placementMode) @@ -60,13 +50,15 @@ namespace NotificationFlyout.Uwp.UI.Controls flyout.ShowAt(_root, new FlyoutShowOptions { Placement = placementMode, - ShowMode = FlyoutShowMode.Standard - }); + ShowMode = FlyoutShowMode.Standard, + }); } protected override void OnApplyTemplate() { _root = GetTemplateChild("Root") as Grid; + _isLoaded = true; + SetFlyoutPlacement(_placement); } } } \ No newline at end of file diff --git a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml index aab084f..8dea152 100644 --- a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml +++ b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHost.xaml @@ -7,20 +7,88 @@ + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHostTemplateSettings.cs b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHostTemplateSettings.cs deleted file mode 100644 index 5aedfdf..0000000 --- a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutHost/NotificationFlyoutHostTemplateSettings.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Windows.UI.Xaml; - -namespace NotificationFlyout.Uwp.UI.Controls -{ - public class NotificationFlyoutHostTemplateSettings : DependencyObject - { - public static readonly DependencyProperty FromHorizontalOffsetProperty = - DependencyProperty.Register(nameof(FromHorizontalOffset), - typeof(double), typeof(NotificationFlyoutHostTemplateSettings), - new PropertyMetadata(0d)); - - public static readonly DependencyProperty FromVerticalOffsetProperty = - DependencyProperty.Register(nameof(FromVerticalOffset), - typeof(double), typeof(NotificationFlyoutHostTemplateSettings), - new PropertyMetadata(0d)); - - public double FromHorizontalOffset - { - get => (double)GetValue(FromHorizontalOffsetProperty); - set => SetValue(FromHorizontalOffsetProperty, value); - } - - public double FromVerticalOffset - { - get => (double)GetValue(FromVerticalOffsetProperty); - set => SetValue(FromVerticalOffsetProperty, value); - } - } -} \ 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 5a4e269..dba0196 100644 --- a/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.xaml +++ b/NotificationFlyout.Uwp.UI.Controls/NotificationFlyoutPresenter/NotificationFlyoutPresenter.xaml @@ -14,11 +14,6 @@ BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}"> - - - - -