Added support common styling properties via NotificationFlyout
This commit is contained in:
+39
-20
@@ -14,38 +14,30 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
||||
typeof(UIElement), typeof(NotificationFlyoutHost),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
public static readonly DependencyProperty FlyoutPresenterStyleProperty =
|
||||
DependencyProperty.Register(nameof(FlyoutPresenterStyle),
|
||||
typeof(Style), typeof(NotificationFlyoutHost),
|
||||
new PropertyMetadata(null));
|
||||
|
||||
private bool _isLoaded;
|
||||
|
||||
private string _placement;
|
||||
|
||||
private Grid _root;
|
||||
|
||||
public NotificationFlyoutHost() => 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;
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@
|
||||
FromVerticalOffset="0" />
|
||||
</TransitionCollection>
|
||||
</Grid.Transitions>
|
||||
<controls:NotificationFlyoutPresenter Content="{TemplateBinding Content}" />
|
||||
<controls:NotificationFlyoutPresenter Content="{TemplateBinding Content}" Style="{TemplateBinding FlyoutPresenterStyle}" />
|
||||
</Grid>
|
||||
</Flyout>
|
||||
</FlyoutBase.AttachedFlyout>
|
||||
|
||||
Reference in New Issue
Block a user