none
如何为XAML元素绘制阴影? RRS feed

  • 问题

  • 如题,我希望阴影不是正投影而是均匀播撒的,也不希望图片资源,效果像是这个示例图片(不要问我图是哪来的~)(我知道这不符合现代设计但我确实需要)
    2015年2月22日 10:46

答案

  • 提供几个思路供你参考下,希望能对你有用

    1,手动添加边框

    <Grid>
        <Border BorderBrush="#14000000" BorderThickness="1" Background="#14000000" CornerRadius="2" Margin="1,1,-1,-1"/>
        <Border BorderBrush="#0F000000" BorderThickness="1" Background="#0F000000" CornerRadius="2.25" Margin="2,2,-2,-2"/>
        <Border BorderBrush="#0C000000" BorderThickness="1" Background="#0C000000" CornerRadius="2.5" Margin="3,3,-3,-3"/>
        <Border BorderBrush="#0A000000" BorderThickness="1" Background="#0A000000" CornerRadius="2.75"  Margin="4,4,-4,-4" />
        <Border BorderBrush="Black" BorderThickness="1" Background="#FFFFFFFF" CornerRadius="2">
            ...Actual content...
        </Border>
    </Grid>
    

    2,使用渐变来绘制阴影

    <Border Grid.Row="1" BorderThickness="0,5,0,5">
        <Border.BorderBrush>
            <LinearGradientBrush StartPoint=".5,0" EndPoint=".5,1">
                <GradientStop Color="Blue" Offset="0"/>
                <GradientStop Color="Black" Offset=".03"/>
                <GradientStop Color="Black" Offset=".98"/>
                <GradientStop Color="Blue" Offset="1"/>
            </LinearGradientBrush>
         </Border.BorderBrush>
    </Border>
    

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2015年3月1日 1:28
    版主

全部回复

  • 您好,

    在windows phone中我们可以用这个class DropShadowEffect来绘制阴影.

    更多信息请参考这篇文章:
    #DropShadowEffect:
    https://msdn.microsoft.com/zh-cn/library/system.windows.media.effects.dropshadoweffect(v=vs.95).aspx .


    ---Amy Peng

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2015年2月23日 11:10
    版主
  • 那么在Windows 和Windows Phone Runtime的应用程序中我该怎么做呢?
    2015年2月23日 13:26
  • 提供几个思路供你参考下,希望能对你有用

    1,手动添加边框

    <Grid>
        <Border BorderBrush="#14000000" BorderThickness="1" Background="#14000000" CornerRadius="2" Margin="1,1,-1,-1"/>
        <Border BorderBrush="#0F000000" BorderThickness="1" Background="#0F000000" CornerRadius="2.25" Margin="2,2,-2,-2"/>
        <Border BorderBrush="#0C000000" BorderThickness="1" Background="#0C000000" CornerRadius="2.5" Margin="3,3,-3,-3"/>
        <Border BorderBrush="#0A000000" BorderThickness="1" Background="#0A000000" CornerRadius="2.75"  Margin="4,4,-4,-4" />
        <Border BorderBrush="Black" BorderThickness="1" Background="#FFFFFFFF" CornerRadius="2">
            ...Actual content...
        </Border>
    </Grid>
    

    2,使用渐变来绘制阴影

    <Border Grid.Row="1" BorderThickness="0,5,0,5">
        <Border.BorderBrush>
            <LinearGradientBrush StartPoint=".5,0" EndPoint=".5,1">
                <GradientStop Color="Blue" Offset="0"/>
                <GradientStop Color="Black" Offset=".03"/>
                <GradientStop Color="Black" Offset=".98"/>
                <GradientStop Color="Blue" Offset="1"/>
            </LinearGradientBrush>
         </Border.BorderBrush>
    </Border>
    

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2015年3月1日 1:28
    版主
  • 扑通!!!
    2015年3月28日 12:36