我正在尝试在后面的代码中创建它。但它抛出“参数不正确”异常。
<VisualState x:Name="FlipCard" >
<Storyboard >
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="aceSpades">
<DiscreteObjectKeyFrame KeyTime="0:0:1">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
代码背后的代码是:
VisualState vst = (VisualState)FindName("FlipCard");
ObjectAnimationUsingKeyFrames anim = new ObjectAnimationUsingKeyFrames();
DiscreteObjectKeyFrame obj = new DiscreteObjectKeyFrame();
obj.Value = Visibility.Visible;
obj.KeyTime = TimeSpan.FromSeconds(1);
anim.KeyFrames.Add(obj);
Storyboard.SetTarget(anim, aceSpades.Projection);
Storyboard.SetTargetProperty(anim, new PropertyPath(Image.VisibilityProperty));
vst.Storyboard.Children.Add(anim);
VisualStateManager.GoToState(this, "FlipCard", true);
它在最后一个代码中抛出错误。