通用Windows应用程序中的投影效果 [英] Drop Shadow effect in Universal Windows Application
问题描述
我正在寻找一种仅使用XAML在WPF中添加投影效果的简便方法。我想将其应用于ListView中的元素。
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.
除了这样的实验,我什么都找不到:
https://blogs.windows.com/buildingapps/ 2016/09/12 /为uwp创建创造美丽效果/#BIRDSebvmJwAFY5Y.97
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.
推荐答案
如果您想自己使用Composition API进行操作,确实可以完成很多工作。幸运的是,我们有了一个很棒的社区,而这些开源项目之一就是 UWP社区工具包。该工具包包含一个 DropShadowPanel 控件,它可以为您完成辛苦的工作。
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>
请注意,您必须为此将应用程序版本设置为10.0.14393.0(周年更新)效果。
Note that you'll have to set the app version to 10.0.14393.0 (Anniversary Update) for this effect.
这篇关于通用Windows应用程序中的投影效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!