Edward Tanguay
Edward Tanguay

Reputation: 193432

How to do silverlight 3 blur effect in code behind?

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...
}

Upvotes: 2

Views: 2508

Answers (1)

Konstantin Tarkus
Konstantin Tarkus

Reputation: 38428

Silverlight 3 only

private void Button1_Click(object sender, RoutedEventArgs e)
{
    ((Button)sender).Content = "was clicked";
    ((Button)sender).Effect = new BlurEffect { Radius = 8 };
}

Upvotes: 1

Related Questions