Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drop Shadow effect in Universal Windows Application

Tags:

c#

.net

xaml

uwp

I'm looking for an easy way to add a Drop Shadow effect like in WPF, using XAML only. I would like to apply it for the elements in a ListView.

I haven't found anything more than experiments like this: https://blogs.windows.com/buildingapps/2016/09/12/creating-beautiful-effects-for-uwp/#BIRDSebvmJwAFY5Y.97

It seems that it would requiere a lot of code-behind. I would like to avoid it. 

like image 554
SuperJMN Avatar asked Dec 22 '16 12:12

SuperJMN


People also ask

What is drop shadow used for?

The drop shadow is often used for elements of a graphical user interface such as windows or menus, and for simple text. The text label for icons on desktops in many desktop environments has a drop shadow, as this effect effectively distinguishes the text from any colored background it may be in front of.

What is a drop shadow image?

What is a drop shadow? Drop shadows give the impression that a layer in your Photoshop project is hovering and casting a shadow onto the background layer beneath it. You can apply a drop shadow to any type of Photoshop layer to help give the impression that your image exists in 3D space.


1 Answers

If you want to do it yourself with the Composition API, it's quite some work indeed. Luckily we got a great community, and one of those open source projects is the UWP Community Toolkit. This toolkit contains a DropShadowPanel control that does the hard work for you.

<controls:DropShadowPanel BlurRadius="4.0"
                          ShadowOpacity="0.70"
                          OffsetX="5.0"
                          OffsetY="5.0"
                          Color="Black">
    <Image Width="200" Source="Unicorn.png" Stretch="Uniform"/>
</controls:DropShadowPanel>    

Note that you'll have to set the app version to 10.0.14393.0 (Anniversary Update) for this effect.

like image 80
Bart Avatar answered Sep 29 '22 18:09

Bart