例如设置Visibility属性时:
第一种方式:
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" FillBehavior="HoldEnd" Storyboard.TargetName="grid"> <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Hidden}"/> <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames>
也就是使用static关键字来赋值。
第二种方式
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" FillBehavior="HoldEnd" Storyboard.TargetName="grid"> <DiscreteObjectKeyFrame KeyTime="0" > <DiscreteObjectKeyFrame.Value> <Visibility>Visible</Visibility> </DiscreteObjectKeyFrame.Value> </DiscreteObjectKeyFrame> </ObjectAnimationUsingKeyFrames>
手动设置要设置的值。