Fade WPF Linear Gradient Brush

I have a brush that colors the title bar. I like how the brush looks, but I would like it to become transparent in the lower 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> 
+6
c # wpf gradient graphics
source share
2 answers

I'm not sure that you can do this by working only at the brush level, however you can apply 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}"> 
+20
source share

just specify the colors as ARGB (including alpha) as follows: #AARRGGBB. Then let the last gradient stop the alpha value of 0 (completely transparent, in your case # 0080A8CC). NTN.

+6
source share

All Articles