简体   繁体   English

Windows Phone 8.1 Runtime中的阴影效果?

[英]Drop shadow effect in Windows Phone 8.1 Runtime?

I'm looking for a way to add a Drop Shadow Effect to the multiple kind of elements in my Windows Phone 8.1 Runtime (not Silverlight!) application. 我正在寻找一种方法来为我的Windows Phone 8.1 Runtime(不是Silverlight!)应用程序中的多种元素添加Drop Shadow Effect The main problem is that.. there's no offical API for it. 主要问题是......它没有正式的API。 The main problem is that I need to mimic this effect not only to the basic shapes (like rectangle or a line), but also a path, like here: 主要的问题是我需要模仿这种效果,不仅是基本的形状(如矩形或线条),还有一个路径,就像这里:

取自问题/ 4519243 / path-with-broken-shadow-effect

Picture is borrowed from this question: path-with-broken-shadow-effect - I hope the owner won't mind ;) Now, he has achieved this effect because it was done in WPF. 图片是从这个问题借来的: 路径与破坏阴影效果 - 我希望主人不介意;)现在,他已经实现了这个效果,因为它是在WPF中完成的。 I'm working on a Universal App (so WinRT), and there's no Effects extension. 我正在使用通用应用程序(所以WinRT),并且没有效果扩展。

I've searched the web multiple times, and found some kind of workarounds, but they all miss something. 我多次搜索网页,发现了某种解决方法,但他们都错过了一些东西。 For example this one: 例如这一个:

http://www.silverlightshow.net/items/Simple-Xaml-Drop-Shadows-in-Silverlight-2.aspx <- I can't work on Canvas , the content has to be a Grid . http://www.silverlightshow.net/items/Simple-Xaml-Drop-Shadows-in-Silverlight-2.aspx < - 我无法在Canvas工作,内容必须是Grid

Do you any idea how can I achieve satisfying results on faking Drop Shadow Effect in Windows Phone 8.1 Runtime? 您知道如何在Windows Phone 8.1 Runtime中伪造投影效果时获得令人满意的效果吗?

Apply a RenderTransform to the shadow shape. RenderTransform应用于阴影形状。 Set the scale to make it bigger: 设置比例以使其更大:

<Grid Style="{StaticResource LayoutRootStyle}" Background="#FF803535" >             
        <Rectangle Width="100" Height="100" Opacity="0.3" RenderTransformOrigin="0,0" StrokeThickness="16" StrokeDashCap="Round" StrokeEndLineCap="Round" StrokeLineJoin="Round" StrokeStartLineCap="Round" Stroke="Black"  >
            <Rectangle.RenderTransform>
                <CompositeTransform ScaleX="1.07" ScaleY="1.07"  />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Width="100" Height="100" Fill="Blue"></Rectangle>
    </Grid>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM