This commit is contained in:
Daniel Clark
2021-02-05 01:39:51 +00:00
parent 666067a36c
commit 45a9eb9cd2
73 changed files with 2669 additions and 0 deletions
@@ -0,0 +1,41 @@
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
namespace NotificationFlyout.Uwp.UI.Controls
{
public class NotificationFlyoutPresenter : ContentControl
{
private Grid _root;
public NotificationFlyoutPresenter()
{
DefaultStyleKey = typeof(NotificationFlyoutPresenter);
}
public void HideFlyout()
{
if (_root == null) return;
var flyout = FlyoutBase.GetAttachedFlyout(_root);
flyout.Hide();
}
public void ShowFlyout(FlyoutPlacementMode placementMode)
{
if (_root == null) return;
var flyout = FlyoutBase.GetAttachedFlyout(_root);
flyout.ShowAt(_root, new FlyoutShowOptions { Placement = placementMode });
}
public void ShowFlyout()
{
if (_root == null) return;
var flyout = FlyoutBase.GetAttachedFlyout(_root);
flyout.ShowAt(_root);
}
protected override void OnApplyTemplate()
{
_root = GetTemplateChild("Root") as Grid;
}
}
}
@@ -0,0 +1,20 @@
<ResourceDictionary
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">
<Style TargetType="controls:NotificationFlyoutPresenter">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:NotificationFlyoutPresenter">
<Grid x:Name="Root">
<FlyoutBase.AttachedFlyout>
<Flyout ShouldConstrainToRootBounds="False" ShowMode="Standard">
<ContentControl Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
</Flyout>
</FlyoutBase.AttachedFlyout>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>