Added shadow support

This commit is contained in:
Daniel Clark
2021-02-07 00:08:10 +00:00
parent 3232f1ac77
commit 8a8410747a
4 changed files with 49 additions and 18 deletions
@@ -2,18 +2,35 @@
x:Class="NotificationFlyout.Sample.NotificationFlyoutPresenter" x:Class="NotificationFlyout.Sample.NotificationFlyoutPresenter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:NotificationFlyout.Uwp.UI.Controls"> xmlns:controls="using:NotificationFlyout.Uwp.UI.Controls"
<Grid> CornerRadius="8">
<ListBox <Grid
Width="300" Width="330"
Height="400" Height="360"
Background="Transparent"> Margin="23">
<ListBoxItem Content="Item 1" /> <Grid.RowDefinitions>
<ListBoxItem Content="Item 2" /> <RowDefinition Height="Auto" />
<ListBoxItem Content="Item 3" /> <RowDefinition Height="Auto" />
<ListBoxItem Content="Item 4" /> </Grid.RowDefinitions>
<ListBoxItem Content="Item 5" /> <TextBlock Text="Quick lauch" />
<ListBoxItem Content="Item 6" /> <GridView Grid.Row="1" HorizontalAlignment="Center">
</ListBox> <GridView.ItemsPanel>
<ItemsPanelTemplate>
<ItemsWrapGrid Orientation="Horizontal" />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<Button
Width="94"
Margin="6,6,3,6"
Content="Test" />
<Button
Width="94"
Margin="3,6,3,6"
Content="Test" />
<Button
Width="94"
Margin="3,6,6,6"
Content="Test" />
</GridView>
</Grid> </Grid>
</controls:NotificationFlyoutPresenter> </controls:NotificationFlyoutPresenter>
@@ -1,6 +1,8 @@
using Windows.UI.Xaml; using System.Numerics;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Media;
namespace NotificationFlyout.Uwp.UI.Controls namespace NotificationFlyout.Uwp.UI.Controls
{ {
@@ -57,6 +59,16 @@ namespace NotificationFlyout.Uwp.UI.Controls
protected override void OnApplyTemplate() protected override void OnApplyTemplate()
{ {
_root = GetTemplateChild("Root") as Grid; _root = GetTemplateChild("Root") as Grid;
if (GetTemplateChild("ContentRoot") is Grid contentRoot)
{
contentRoot.Shadow = new ThemeShadow();
var currentTranslation = contentRoot.Translation;
var translation = new Vector3(currentTranslation.X, currentTranslation.Y, 16.0f);
contentRoot.Translation = translation;
}
_isLoaded = true; _isLoaded = true;
SetFlyoutPlacement(_placement); SetFlyoutPlacement(_placement);
} }
@@ -45,16 +45,17 @@
AreOpenCloseAnimationsEnabled="False" AreOpenCloseAnimationsEnabled="False"
FlyoutPresenterStyle="{StaticResource BottomFlyoutPresenterStyle}" FlyoutPresenterStyle="{StaticResource BottomFlyoutPresenterStyle}"
ShouldConstrainToRootBounds="False"> ShouldConstrainToRootBounds="False">
<ContentControl Content="{TemplateBinding FlyoutPresenter}"> <Grid x:Name="ContentRoot">
<ContentControl.Transitions> <Grid.Transitions>
<TransitionCollection> <TransitionCollection>
<EntranceThemeTransition <EntranceThemeTransition
x:Name="EntranceThemeTransition" x:Name="EntranceThemeTransition"
FromHorizontalOffset="0" FromHorizontalOffset="0"
FromVerticalOffset="0" /> FromVerticalOffset="0" />
</TransitionCollection> </TransitionCollection>
</ContentControl.Transitions> </Grid.Transitions>
</ContentControl> <ContentControl Content="{TemplateBinding FlyoutPresenter}" />
</Grid>
</Flyout> </Flyout>
</FlyoutBase.AttachedFlyout> </FlyoutBase.AttachedFlyout>
<VisualStateManager.VisualStateGroups> <VisualStateManager.VisualStateGroups>
@@ -8,6 +8,7 @@
<Setter.Value> <Setter.Value>
<ControlTemplate TargetType="controls:NotificationFlyoutPresenter"> <ControlTemplate TargetType="controls:NotificationFlyoutPresenter">
<Border <Border
x:Name="Root"
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
BackgroundSizing="OuterBorderEdge" BackgroundSizing="OuterBorderEdge"