how to change the height of a grid row in wpf using storyboard

懵懂的女人 提交于 2019-12-14 01:11:36

问题


I have a Grid with 2 rows:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="150"/>
        <RowDefinition />
        <RowDefinition Height="Auto" x:Name="OtherContactsRow" />
    </Grid.RowDefinitions>
    Something here
</Grid>

and 2 Storyboards:

<Storyboard x:Key="MaximizedStoryboard">
    <DoubleAnimation From="20" To="150"  Duration="0:0:2"
                     Storyboard.TargetName="OtherContactsRow"
                     Storyboard.TargetProperty="Height" >    
    </DoubleAnimation>
</Storyboard>

<Storyboard x:Key="MinimizedStoryboard">
    <DoubleAnimation From="150" To="20" Duration="0:0:2"
                     Storyboard.TargetName="OtherContactsRow"
                     Storyboard.TargetProperty="Height">
    </DoubleAnimation>
</Storyboard>

When I try to modify the height of the row named OtherContactsRow I received the following error:

'System.Windows.Media.Animation.DoubleAnimation' animation object cannot be used to animate property 'Height' because it is of incompatible type 'System.Windows.GridLength'.

Any solutions?


回答1:


You could try the ActualHeight property. It is a double.



来源:https://stackoverflow.com/questions/2017448/how-to-change-the-height-of-a-grid-row-in-wpf-using-storyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!