66 xmlns:ui="using:Microsoft.Toolkit.Uwp.UI"
77 xmlns:media="using:Microsoft.Toolkit.Uwp.UI.Media"
88 mc:Ignorable="d">
9-
10- <!-- TODO: Show using as Resource as well... -->
119
12- <Grid>
13- <Button Content="Hello Shadows!" HorizontalAlignment="Center" VerticalAlignment="Center"
14- CornerRadius="8">
15- <ui:Effects.Shadow>
16- <media:AttachedCardShadow BlurRadius="@[BlurRadius:DoubleSlider:8.0:0.0-10.0]"
17- CornerRadius="8"
18- Color="@[Color:Brush:Black]"
19- Offset="@[Offset:Vector3:16,16]"
20- Opacity="@[Opacity:DoubleSlider:1.0:0.0-1.0]"/>
21- </ui:Effects.Shadow>
22- </Button>
23- </Grid>
24- </Page>
10+ <!-- TODO: Animation-->
11+ <Page.Resources>
12+ <media:AttachedCardShadow x:Key="CommonShadow" Offset="4"/>
13+
14+ <Style TargetType="Button" BasedOn="{StaticResource DefaultButtonStyle}">
15+ <Setter Property="ui:Effects.Shadow" Value="{StaticResource CommonShadow}"/>
16+ <Setter Property="HorizontalAlignment" Value="Center"/>
17+ </Style>
18+ </Page.Resources>
19+
20+ <ScrollViewer>
21+ <StackPanel Spacing="32" VerticalAlignment="Center">
22+ <!-- All buttons on this page have the shadow from the common style!
23+ The Shadow definition is Shared! -->
24+ <Button Content="I Have a Shadow!"/>
25+ <!-- Can apply the same shadow to any type of element! -->
26+ <Image ui:Effects.Shadow="{StaticResource CommonShadow}"
27+ Height="100" Width="100"
28+ Source="ms-appx:///Assets/Photos/Owl.jpg"/>
29+ <!-- You can still apply a Shadow directly and even use binding with it to manipulate at runtime! -->
30+ <Rectangle RadiusX="32" RadiusY="32"
31+ Height="100" Width="100"
32+ Stroke="Blue" StrokeThickness="1">
33+ <Rectangle.Fill>
34+ <ImageBrush ImageSource="ms-appx:///Assets/Photos/Owl.jpg"/>
35+ </Rectangle.Fill>
36+ <ui:Effects.Shadow>
37+ <media:AttachedCardShadow BlurRadius="@[BlurRadius:DoubleSlider:8.0:0.0-10.0]"
38+ CornerRadius="32"
39+ Color="@[Color:Brush:Black]"
40+ Offset="@[Offset:Vector3:4,4]"
41+ Opacity="@[Opacity:DoubleSlider:1.0:0.0-1.0]"/>
42+ </ui:Effects.Shadow>
43+ </Rectangle>
44+ <Border CornerRadius="32"
45+ Height="100" Width="100"
46+ BorderBrush="White" BorderThickness="1">
47+ <Border.Background>
48+ <ImageBrush ImageSource="ms-appx:///Assets/Photos/Owl.jpg"/>
49+ </Border.Background>
50+ <!-- TODO: Doesn't work? -->
51+ <ui:Effects.Shadow>
52+ <media:AttachedCardShadow CornerRadius="32"
53+ Offset="4,4"/>
54+ </ui:Effects.Shadow>
55+ </Border>
56+ <!-- Note how even though this element is transparent, the shadow only shows on its edges still! -->
57+ <Rectangle ui:Effects.Shadow="{StaticResource CommonShadow}"
58+ Fill="#80FF0000"
59+ RadiusX="4" RadiusY="4"
60+ Width="200" Height="100"/>
61+ <!-- Compared to the old DropShadowPanel where the shadow bleeds through and
62+ the Shadow opacity is tied to the Rectangle itself -->
63+ <controls:DropShadowPanel xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
64+ OffsetX="4" OffsetY="4"
65+ BlurRadius="12"
66+ HorizontalAlignment="Center">
67+ <Rectangle Fill="#80FF0000"
68+ RadiusX="4" RadiusY="4"
69+ Width="200" Height="100"/>
70+ </controls:DropShadowPanel>
71+ <Button Content="I Also have a Shadow!"/>
72+ </StackPanel>
73+ </ScrollViewer>
74+ </Page>
0 commit comments