Added support common styling properties via NotificationFlyout
This commit is contained in:
@@ -6,12 +6,17 @@
|
|||||||
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
|
||||||
IconSource="/Assets/Icon.ico"
|
IconSource="/Assets/Icon.ico"
|
||||||
LightIconSource="/Assets/Icon-Light.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:NotificationFlyout.ContextMenu>
|
||||||
<controls:NotificationFlyoutContextMenu>
|
<controls:NotificationFlyoutContextMenu>
|
||||||
<MenuFlyoutItem Click="MenuFlyoutItem_Click" Text="Close" />
|
<MenuFlyoutItem Click="MenuFlyoutItem_Click" Text="Close" />
|
||||||
</controls:NotificationFlyoutContextMenu>
|
</controls:NotificationFlyoutContextMenu>
|
||||||
</controls:NotificationFlyout.ContextMenu>
|
</controls:NotificationFlyout.ContextMenu>
|
||||||
<StackPanel Margin="24">
|
<StackPanel Height="500" Margin="24">
|
||||||
<ComboBox
|
<ComboBox
|
||||||
x:Name="Theme"
|
x:Name="Theme"
|
||||||
Margin="0,0,0,8"
|
Margin="0,0,0,8"
|
||||||
|
|||||||
+39
-20
@@ -14,38 +14,30 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
|||||||
typeof(UIElement), typeof(NotificationFlyoutHost),
|
typeof(UIElement), typeof(NotificationFlyoutHost),
|
||||||
new PropertyMetadata(null));
|
new PropertyMetadata(null));
|
||||||
|
|
||||||
|
public static readonly DependencyProperty FlyoutPresenterStyleProperty =
|
||||||
|
DependencyProperty.Register(nameof(FlyoutPresenterStyle),
|
||||||
|
typeof(Style), typeof(NotificationFlyoutHost),
|
||||||
|
new PropertyMetadata(null));
|
||||||
|
|
||||||
private bool _isLoaded;
|
private bool _isLoaded;
|
||||||
|
|
||||||
private string _placement;
|
private string _placement;
|
||||||
|
|
||||||
private Grid _root;
|
private Grid _root;
|
||||||
|
|
||||||
public NotificationFlyoutHost() => DefaultStyleKey = typeof(NotificationFlyoutHost);
|
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
|
public UIElement Content
|
||||||
{
|
{
|
||||||
get => (UIElement)GetValue(ContentProperty);
|
get => (UIElement)GetValue(ContentProperty);
|
||||||
set => SetValue(ContentProperty, value);
|
set => SetValue(ContentProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Style FlyoutPresenterStyle
|
||||||
|
{
|
||||||
|
get => (Style)GetValue(FlyoutPresenterStyleProperty);
|
||||||
|
set => SetValue(FlyoutPresenterStyleProperty, value);
|
||||||
|
}
|
||||||
public void HideFlyout()
|
public void HideFlyout()
|
||||||
{
|
{
|
||||||
if (_root == null) return;
|
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()
|
protected override void OnApplyTemplate()
|
||||||
{
|
{
|
||||||
_root = GetTemplateChild("Root") as Grid;
|
_root = GetTemplateChild("Root") as Grid;
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@
|
|||||||
FromVerticalOffset="0" />
|
FromVerticalOffset="0" />
|
||||||
</TransitionCollection>
|
</TransitionCollection>
|
||||||
</Grid.Transitions>
|
</Grid.Transitions>
|
||||||
<controls:NotificationFlyoutPresenter Content="{TemplateBinding Content}" />
|
<controls:NotificationFlyoutPresenter Content="{TemplateBinding Content}" Style="{TemplateBinding FlyoutPresenterStyle}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Flyout>
|
</Flyout>
|
||||||
</FlyoutBase.AttachedFlyout>
|
</FlyoutBase.AttachedFlyout>
|
||||||
|
|||||||
Reference in New Issue
Block a user