Added support common styling properties via NotificationFlyout
This commit is contained in:
@@ -6,12 +6,17 @@
|
||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||
IconSource="/Assets/Icon.ico"
|
||||
LightIconSource="/Assets/Icon-Light.ico">
|
||||
<controls:NotificationFlyout.FlyoutPresenterStyle>
|
||||
<Style TargetType="controls:NotificationFlyoutPresenter">
|
||||
<Setter Property="CornerRadius" Value="8" />
|
||||
</Style>
|
||||
</controls:NotificationFlyout.FlyoutPresenterStyle>
|
||||
<controls:NotificationFlyout.ContextMenu>
|
||||
<controls:NotificationFlyoutContextMenu>
|
||||
<MenuFlyoutItem Click="MenuFlyoutItem_Click" Text="Close" />
|
||||
</controls:NotificationFlyoutContextMenu>
|
||||
</controls:NotificationFlyout.ContextMenu>
|
||||
<StackPanel Margin="24">
|
||||
<StackPanel Height="500" Margin="24">
|
||||
<ComboBox
|
||||
x:Name="Theme"
|
||||
Margin="0,0,0,8"
|
||||
|
||||
+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