调整数据网格大小不起作用

时间:2012-09-25 10:28:40

标签: wpf animation datagrid

我可以在窗口中调整datagrid的大小,直到我执行此代码:

    // Handle the tabcontrol animation 
DoubleAnimation dbTbViewsAnimation =
    new DoubleAnimation(dToTabHeightParameter, new Duration(new TimeSpan(0,0,1)));
this.tbViews.BeginAnimation(TabControl.HeightProperty, dbTbViewsAnimation);


// Handle the tabcontrol animation 
DoubleAnimation dbCurrentPlaylistHeightAnimation =
    new DoubleAnimation(dToCurrentPlaylistParameter, new Duration(new TimeSpan(0, 0, 1)));
this.dgCurrentPlaylist.BeginAnimation(DataGrid.HeightProperty, dbCurrentPlaylistHeightAnimation);

此代码中的问题是什么以及阻止数据网格大小调整的原因? 谢谢!

1 个答案:

答案 0 :(得分:0)

Timeline.FillBehavior Property。默认值为HoldEnd。您可以使用构造函数重载来更改此行为。

DoubleAnimation dbTbViewsAnimation =
    new DoubleAnimation(dToTabHeightParameter,
                        new Duration(new TimeSpan(0,0,1)),
                        FillBehavior.Stop);

仅供参考:How to: Set a Property After Animating It with a Storyboard