I'm trying to animate a Border control's width in a Windows 8 Metro app. I've managed to animate other properties on the Border, such as Opacity:
private void Item_Tapped(object sender, RoutedEventArgs e)
{
var border = sender as Border;
var animation = new DoubleAnimation();
animation.To = 0.0;
animation.Duration = new Duration(TimeSpan.FromSeconds(1));
var storyboard = new Storyboard();
storyboard.Children.Add(animation);
Storyboard.SetTarget(animation, border);
Storyboard.SetTargetProperty(animation, "Opacity");
storyboard.Begin();
}
But when I try to animate the width of the control:
private void Item_Tapped(object sender, RoutedEventArgs e)
{
var border = sender as Border;
var animation = new DoubleAnimation();
animation.To = 600.0;
animation.Duration = new Duration(TimeSpan.FromSeconds(1));
var storyboard = new Storyboard();
storyboard.Children.Add(animation);
Storyboard.SetTarget(animation, border);
Storyboard.SetTargetProperty(animation, "Width");
storyboard.Begin();
}
Nothing happens.
I am able to do this in WPF, but not in Windows 8. Is this a limitation or bug of Metro, or am I doing something wrong?
Thanks