Unable to animate custom control object's width property. RRS feed

  • Question

  • I have a custom control that is a child of a canvas. When you double click this object (TaskCard), I would like for the object's height and width to expand. Can anyone tell me why this won't work? I get no errors when running it.


    private void taskCard_DoubleClick(object sender, MouseButtonEventArgs e)


    // Create a DoubleAnimation to animate the width.

    DoubleAnimation myDoubleAnimation = new DoubleAnimation();

    myDoubleAnimation.From = 200;

    myDoubleAnimation.To = 500;

    myDoubleAnimation.Duration = new Duration(TimeSpan.FromMilliseconds(3000));

    // Configure the animation to target the TaskCard's Width property.

    Storyboard.SetTargetName(myDoubleAnimation, ((TaskCard)(sender)).Name);

    Storyboard.SetTargetProperty(myDoubleAnimation, new PropertyPath(TaskCard.WidthProperty));

    // Create a storyboard to contain the animation.

    Storyboard myWidthAnimationStoryboard = new Storyboard();




    Tuesday, October 10, 2006 4:08 PM