Apply Opacity to LinearGradientBrush
-
13-11-2019 - |
Pregunta
I have a LinearGradientBrush defined as follows. I want to use this somewhere in my xaml but I want to change the opacity in this particular case (only in this instance, not everywhere I use it). Any ideas how to accomplish this?
<LinearGradientBrush x:Key="BlueBackgroundBrush" EndPoint="0.874,1.197" StartPoint="0.126,-0.197">
<GradientStop Color="#1954B2" />
<GradientStop Color="#1954B2" Offset="0.982" />
<GradientStop Color="#FF84B2D4" Offset="0.304" />
</LinearGradientBrush>
Solución
Nevermind, I figured it out. I modified from this question: Use a LinearGradientBrush in another LinearGradientBrush?
to end up with:
<GradientStopCollection x:Key="BlueBackgroundStops">
<GradientStop Color="#1954B2" />
<GradientStop Color="#1954B2" Offset="0.982" />
<GradientStop Color="#FF84B2D4" Offset="0.304" />
</GradientStopCollection>
and to use it:
<LinearGradientBrush EndPoint="0.874,1.197" StartPoint="0.126,-0.197"
GradientStops="{StaticResource BlueBackgroundStops}"
Opacity=".65"/>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow