我有一个可以通过代码控制Visibility的网格。我希望网格在变为可见之后被隐藏,比如说在5秒之后。在WPF中有什么简单的方法吗?
答案 0 :(得分:1)
你可以在Opacity属性上使用DoubleAnimationUsingKeyFrames的故事板(这只会隐藏网格,而不是折叠它)。
答案 1 :(得分:0)
添加以下代码:
<Window.Resources>
<Storyboard x:Key="HideGridSB">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:05.000000" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource HideGridSB}"/>
</EventTrigger>
</Window.Triggers>