tags:

views:

47

answers:

1

Hi :),

I've a little problem, I'd search google and my Wpf's books but I don't found any answer :(

I have created a little storyboard :

<Storyboard x:Key="whiteAnim" Duration="1">
        <ColorAnimation By="Black" To="White" Storyboard.TargetProperty="Background" x:Name="step1"/>
        <ColorAnimation By="White" To="Black" Storyboard.TargetProperty="Background" x:Name="step2"/>
</Storyboard>

This animation will change background color from black to white, and from white to black. I want to "apply" this storyboard to a Label :

Label label = new Label();
label.Content = "My label";

I'm looking for a method like "label.StartStoryboard(--myStoryboard--), do you have any ideas ?

Thank you :)

+2  A: 

It should work with

public void StartStoryboard() {
  whiteAnim.Target = label;
  whiteAnim.Begin();
}

or

public void StartStoryboard() {
  Storyboard.SetTarget(whiteAnim, label);
  whiteAnim.Begin();
}
Jehof
Thank you it works fine :)
ThitoO