Set visibility with a trigger
I just want to start an storyboard which makes an rectangle visible for 2 seconds when user pressed with left mouse button. But I could not solve how to get the visibility value.
<Grid.Triggers>
<EventTrigger RoutedEvent="MouseDown" >
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="0:0:0" Duration="0:0:2" Storyboard.TargetName="RectFront" Storyboard.TargetProperty="Visibility">
<LinearDoubleKeyFrame KeyTime="0:0:0.100" Value="1" />
开发者_如何转开发 <LinearDoubleKeyFrame KeyTime="0:0:2" Value="0" /> <--- HOW to change this into Visibility Type?
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Grid.Triggers>
For example:
Value="{x:Static Visibility.Hidden}"
but in some cases the XAML parser can just convert a normal string like Value="Hidden" as well.
A problem here is though that to animate Visibility you cannot use a DoubleAnimationUsingKeyFrames, it has to be an ObjectAnimationUsingKeyFrames.
If you want to animate visibility gradually you can use a DoubleAnimation (with or without keyframes) but you need to target the Opacity instead.
加载中,请稍侯......
精彩评论