线性渐变画笔淡出WPF [英] Linear Gradient Brush Fade WPF
本文介绍了线性渐变画笔淡出WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个刷子颜色头的背景。我喜欢的方式刷的外貌,但希望它褪色透明倒数第三。任何想法如何做到这一点。
<一个LinearGradientBrush
X:键=HeaderBackgroundBrush
终点= .5,1
StartPoint可以=1,0>
<渐变停止颜色=#006699偏移量=1/>
<渐变停止颜色=#80A8CC偏移量=0.5/>
< /一个LinearGradientBrush>
解决方案
我不知道,你可以通过努力做到这一点只在刷级,但你可以申请一个 OpacityMask
您的控制:
<一个LinearGradientBrush
X:键=HeaderBackgroundOpacityMask
StartPoint可以=0,0
终点=0.1>
<渐变停止颜色=#FFFFFFFF偏移量=0/>
<渐变停止颜色=#FFFFFFFF偏移量=0.667/>
<渐变停止颜色=#00FFFFFF偏移量=1/>
< /一个LinearGradientBrush>
:
<边框背景={StaticResource的HeaderBackgroundBrush}
OpacityMask ={StaticResource的HeaderBackgroundOpacityMask}>
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>
解决方案
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屋!
查看全文