The following code is was originally part of a WPF app that I'm converting over to WinRT; however, when trying to run the animations, they appear to be mutually exclusive (that is, they both work, but only one at a time - whereas in WPF I could run them together):
private void SpinAndDisappear_Click(object sender, RoutedEventArgs e)
{
UIElement obj = (UIElement)SpinAndDisappear;
obj.RenderTransform = new CompositeTransform();
var story = new Storyboard();
var xAnim = new DoubleAnimation();
var yAnim = new DoubleAnimation();
xAnim.Duration = TimeSpan.FromSeconds(2);
yAnim.Duration = TimeSpan.FromSeconds(2);
xAnim.To = 0;
yAnim.To = 0;
story.Children.Add(xAnim);
story.Children.Add(yAnim);
Storyboard.SetTarget(xAnim, obj);
Storyboard.SetTarget(yAnim, obj);
Storyboard.SetTargetProperty(xAnim, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
Storyboard.SetTargetProperty(yAnim, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
story.Begin();
SpinAnimation(); // If commented out, the button changes size,
// and if not, it spins, but not both
}
void SpinAnimation()
{
UIElement obj = (UIElement)SpinAndDisappear;
obj.RenderTransform = new RotateTransform();
var storySpin = new Storyboard();
var spinAnim = new DoubleAnimation();
spinAnim.Duration = TimeSpan.FromSeconds(2);
spinAnim.From = 0;
spinAnim.To = 360;
storySpin.Children.Add(spinAnim);
Storyboard.SetTarget(spinAnim, obj);
Storyboard.SetTargetProperty(spinAnim, "(UIElement.RenderTransform).(RotateTranform.Angle)");
storySpin.Begin();
}
So my question is: how to do both simultaneously in WinRT?