当动画网格列宽度变化 [英] Grid Column changing Width when animating

查看:108
本文介绍了当动画网格列宽度变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有有两列三行网格元素。最后一行具有的高度为0 ...我使用的是自定义动画类,因为gridheight属性心不是一个整数动画height属性。

I have a Grid element that has two columns and three rows. The last row has a height of 0... and I animate the height property using a custom animation class because the gridheight property isnt an integer..

动画工作得很好,但是当我激活它,它似乎是随机变化的第二列的宽度..有时只是几个像素更大,有时超过双宽...

The animation works just fine, but when I activate it, it changes the width of the second column seemingly randomly.. sometimes just a few pixels bigger and sometimes over double as wide...

下面是网格code

<Grid >
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="50"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="1*" />
                            <RowDefinition Height="7"/>
                            <RowDefinition Name="LyricsRow" Height="1">

                                <RowDefinition.Style>
                                    <Style>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=IsTrayOpen}" Value="True">
                                                <DataTrigger.EnterActions>
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <local:GridLengthAnimation
                                                              Storyboard.TargetProperty="Height"
                                                              From="0" To="150" Duration="0:0:0.3" >
                                                            </local:GridLengthAnimation>
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </DataTrigger.EnterActions>
                                                <DataTrigger.ExitActions>
                                                    <BeginStoryboard>
                                                        <Storyboard>
                                                            <local:GridLengthAnimation
                                                              Storyboard.TargetProperty="Height"
                                                              From="150" To="0" Duration="0:0:0.5" />
                                                        </Storyboard>
                                                    </BeginStoryboard>
                                                </DataTrigger.ExitActions>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </RowDefinition.Style>

                            </RowDefinition>
                        </Grid.RowDefinitions>

是否有这可能进行的任何原因?

Is there any reasons this could be going on?

推荐答案

这可能取决于细胞的内容

It probably depends on the content of the "cells"

尝试,除了宽度=50在你的columnDefinition设置了maxWidth =50

try setting MaxWidth="50" on your columnDefinition in addition to Width="50"

这篇关于当动画网格列宽度变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆