线性渐变画笔淡入淡出 WPF [英] Linear Gradient Brush Fade WPF
本文介绍了线性渐变画笔淡入淡出 WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个画笔,可以为页眉的背景着色.我喜欢画笔的外观,但希望它在底部三分之一处淡化为透明.任何想法如何做到这一点?
I have a brush that colors the background of a header. I like the way the brush looks but would like it to fade to transparent in the bottom third. Any ideas how to do this?
<LinearGradientBrush
x:Key="HeaderBackgroundBrush"
EndPoint=".5,1"
StartPoint="1,0">
<GradientStop Color="#006699" Offset="1"/>
<GradientStop Color="#80A8CC" Offset="0.5"/>
</LinearGradientBrush>
推荐答案
我不确定您是否可以仅在画笔级别工作,但您可以将 OpacityMask
应用于您的控件:
I'm not sure you can do it by working only at the brush level, however you could apply an OpacityMask
to your control:
<LinearGradientBrush
x:Key="HeaderBackgroundOpacityMask"
StartPoint="0,0"
EndPoint="0,1">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#FFFFFFFF" Offset="0.667"/>
<GradientStop Color="#00FFFFFF" Offset="1"/>
</LinearGradientBrush>
...
<Border Background="{StaticResource HeaderBackgroundBrush}"
OpacityMask="{StaticResource HeaderBackgroundOpacityMask}">
这篇关于线性渐变画笔淡入淡出 WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文