views:

979

answers:

1

The blur effect in silverlight 3 is nice:

<StackPanel HorizontalAlignment="Left">
    <Button x:Name="Button1"
    Content="Click This"
    Click="Button1_Click">
        <Button.Effect>
            <BlurEffect Radius="2"/>
        </Button.Effect>
    </Button>
</StackPanel>

But how would I do it in code behind:

private void Button1_Click(object sender, RoutedEventArgs e)
{
    Button1.Content = "was clicked";
    //Button1.Effect.bl...
}
+1  A: 

Silverlight 3 only

private void Button1_Click(object sender, RoutedEventArgs e)
{
    ((Button)sender).Content = "was clicked";
    ((Button)sender).Effect = new BlurEffect { Radius = 8 };
}
Koistya Navin
thanks, note you also need: using System.Windows.Media.Effects;
Edward Tanguay