【发布时间】:2013-11-18 20:36:19
【问题描述】:
我正在尝试使用 Storyboard 将 WPF 网格的高度从 0 更改为 Auto。我知道我不能不欺骗就做到这一点,所以我尝试使用情节提要中的数据绑定来更改 MaxHeight 值。但我不能让它工作(高度总是等于0)。这是我使用的代码:
两种视觉状态:
<VisualState x:Name="SelectionMode">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="CurrentToolGrid" Storyboard.TargetProperty="(FrameworkElement.MaxHeight)">
<EasingDoubleKeyFrame KeyTime="0" Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="EditionMode">
<Storyboard>
<DoubleAnimationUsingKeyFrames Storyboard.TargetName="CurrentToolGrid" Storyboard.TargetProperty="(FrameworkElement.MaxHeight)">
<EasingDoubleKeyFrame KeyTime="0" Value="{Binding ElementName=CurrentToolGrid, Path=ActualHeight}" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
这是我的网格定义:
<Grid x:Name="CurrentToolGrid" Background="#FFDEDEDE" Grid.Row="1" Height="Auto">
[... some controls that extends the grid's height ...]
</Grid>
为什么 CurrentToolGrid 的高度总是 0 ?
谢谢你帮助我:)
【问题讨论】:
-
我想你想在 Editing 模式时隐藏 ToolGrid,在 SelectionMode 时显示 ToolGrid,那么为什么不尝试将 ToolGrid 的 Visibility 属性设置在 Visible 和 Collapsed 之间呢?
-
因为我想让它向上滑动。
标签: wpf storyboard