通用 Windows 应用程序中的投影效果 [英] Drop Shadow effect in Universal Windows Application
问题描述
我正在寻找一种简单的方法来添加像在 WPF 中一样的投影效果,仅使用 XAML.我想将它应用于 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/creating-beautiful-effects-for-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屋!