Introduced a NotificationFlyoutPresenter to allow you to restyle/retemplate the flyout from within your UWP app
This commit is contained in:
+1
-60
@@ -1,71 +1,12 @@
|
||||
using Windows.UI.Popups;
|
||||
using Windows.UI.ViewManagement;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace NotificationFlyout.Uwp.UI.Controls
|
||||
{
|
||||
public class NotificationFlyoutPresenter : ContentControl
|
||||
{
|
||||
public static readonly DependencyProperty TemplateSettingsProperty =
|
||||
DependencyProperty.Register(nameof(TemplateSettings),
|
||||
typeof(NotificationFlyoutPresenterTemplateSettings), typeof(NotificationFlyoutPresenter),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
private Grid _root;
|
||||
private NotificationFlyoutPresenterTemplateSettings _templateSettings;
|
||||
|
||||
public NotificationFlyoutPresenter()
|
||||
{
|
||||
DefaultStyleKey = typeof(NotificationFlyoutPresenter);
|
||||
|
||||
_templateSettings = new NotificationFlyoutPresenterTemplateSettings();
|
||||
SetValue(TemplateSettingsProperty, _templateSettings);
|
||||
|
||||
UISettings uiSettings = new UISettings();
|
||||
uiSettings.ColorValuesChanged += UiSettings_ColorValuesChanged;
|
||||
}
|
||||
|
||||
private void UiSettings_ColorValuesChanged(UISettings sender, object args)
|
||||
{
|
||||
MessageDialog d = new MessageDialog("", "");
|
||||
}
|
||||
|
||||
public NotificationFlyoutPresenterTemplateSettings TemplateSettings
|
||||
{
|
||||
get => (NotificationFlyoutPresenterTemplateSettings)GetValue(TemplateSettingsProperty);
|
||||
set => SetValue(TemplateSettingsProperty, value);
|
||||
}
|
||||
|
||||
public void SetOffset(double verticalOffset, double horizontalOffset)
|
||||
{
|
||||
if (_templateSettings == null) return;
|
||||
_templateSettings.FromVerticalOffset = verticalOffset;
|
||||
_templateSettings.FromHorizontalOffset = horizontalOffset;
|
||||
}
|
||||
|
||||
public void HideFlyout()
|
||||
{
|
||||
if (_root == null) return;
|
||||
FlyoutBase 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,
|
||||
ShowMode = FlyoutShowMode.Standard
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnApplyTemplate()
|
||||
{
|
||||
_root = GetTemplateChild("Root") as Grid;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user