开发者

UserControl Shadow

开发者 https://www.devze.com 2022-12-26 05:00 出处:网络
I have a user control, MBControl. Here is the code: <my:MBControl Name=\"MBControl\" HorizontalAlignment=\"Center\" VerticalAlignment=\"Center\">

I have a user control, MBControl. Here is the code:

<my:MBControl Name="MBControl" HorizontalAlignment="Center" VerticalAlignment="Center">
              <my:MBControl.BitmapEffect>
                <DropShadowBitmapEffect Color="Black" Dir开发者_如何学编程ection="315"
                      Softness="0.5" ShadowDepth="10" Opacity="1" />
              </my:MBControl.BitmapEffect>
</my:MBControl>

The problem with the code is it seems like the shadow is applied to every child element of my user control. Or, possibly, it is dropped inside as well as outside -- the control surface is darker than without the shadow.

How could I fix this? I want the shadow being dropped outside only and not affecting the control surface.

UPDATE: I've got it! This effect is the result of the user control transparency. The shadow has a form of rectangle (like my user control's form). What I really want is a shadow with subtracted central area. This area has to be intersection of it's current shape and user control shape.


Setting a non-transparent background color should suffice:

<my:MBControl ... Background="White">
    ...
</my:MBControl>
0

精彩评论

暂无评论...
验证码 换一张
取 消