Saturday, April 12, 2008

XAML - Brushes - Gradient Brushes Part 3

So for the third post of the Gradient Brushes, here is an example to how you can use the gradient brushes on test and to fill a Path object representing a triangle


Code


<StackPanel>

<TextBlock FontSize="50" Text="Sample">
<TextBlock.Foreground>
<RadialGradientBrush>
<GradientStop Offset="1" Color="Red"/>
<GradientStop Offset="0.5" Color="Purple"/>
<GradientStop Offset="0" Color="Blue"/>
</RadialGradientBrush>
</TextBlock.Foreground>
</TextBlock>

<Path Stroke="Black" Data="M 80,0 0,160 160,160 80,0">
<Path.Fill>
<RadialGradientBrush GradientOrigin="0.5,0">
<GradientStop Offset="1.5" Color="Red"/>
<GradientStop Offset="0.5" Color="Purple"/>
<GradientStop Offset="0" Color="Blue"/>
</RadialGradientBrush>
</Path.Fill>
</Path>

</StackPanel>


Screenshot

No comments: