21 August 2009

Apply gradients to controls in wpf



  • Open wpf application template
  • Write code as below

</Window>

<Window.Background>

<LinearGradientBrush>
<GradientStop Color="blue" Offset="0.2"/>

<GradientStop Color="Yellow" Offset="0.6"/>

<GradientStop Color="Orange" Offset="0.8"/>

</LinearGradientBrush>

</Window.Background>

<Grid>

<Button Content="Click" Width="200" Height="50">

<Button.Background>

<RadialGradientBrush>

<GradientStop Color="Violet"
Offset="0.9"/>

<GradientStop Color="red" Offset="0.1"/>

<GradientStop Color="Yellow" Offset="0.5"/>

<GradientStop Color="Pink" Offset="0.99"/>

</RadialGradientBrush>

</Button.Background>

</Button>

</Grid>

</Window>

  • Now Execute the project by clicking the F5