WPF Grid/WrapPanel AutoSize 动画

发布于 2024-08-21 16:17:32 字数 464 浏览 2 评论 0原文

我在 WPF 中使用 MVVM 具有以下布局

<grid>
<row height=auto>
<border>
<listbox>
<border?
</row>
<row height=*>
<othercontent>
</row>
</grid>

,并绑定了列表框项目源。我在网格中使用了一个wrapPanel,并禁用了滚动,因此网格行高将根据列表框内容增大和缩小。这一切工作正常。

我想要的是能够对列表框(或包含它的边框,或具有自动高度的网格行)的增长和收缩进行动画处理。我应该使用什么元素 - 边框上的 SizeChanged 触发器?

另外,当我的 ItemsSource 更改时,我希望列表框项目淡出,然后调整大小,然后新项目淡入。

非常感谢任何帮助。 谢谢, 克里斯

I have the following layout in WPF

<grid>
<row height=auto>
<border>
<listbox>
<border?
</row>
<row height=*>
<othercontent>
</row>
</grid>

Using MVVM and have listbox itemsource bound. I am using a wrapPanel in the grid, and have scrolling disabled so the Grid row height will grow and shrink based on the list box contents. This is all working fine.

What I would like, is to be able to animate the growing and shrinking of the listbox (or the border containing it, or the grid row that has the auto-height). What element should I be using - a trigger on SizeChanged on the border?

Also I when my ItemsSource changes, I would like my listbox items to fade out, then the resize, then the new items to fade in.

Any help much appreciated.
Thanks,
Chris

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情深如许 2024-08-28 16:17:32

我认为您需要创建自己的 WrapPanel。也许已经有第 3 方控件可以满足您的要求。

不知道如何做到这一点。但是定制的包裹面板。在尺寸更改时,检查行上是否有空间容纳项目。如果是这样,则执行故事板,该故事板将为项目的位置设置动画。

另请查看视觉状态管理器。如果使用流体布局,您将能够为不具有动画效果的内容添加动画效果。就像将 uielement 从网格列移到另一个网格列一样。

不确定这是否有任何帮助。

I think you would need to create you own WrapPanel. Perhaps there already is a 3rd party control out there that does what you want.

Not sure how this could be done. But a custom wrap panel. On size change check if there is room for item on row. If so execute storyboars that will animate the item's position.

Also take a look at visual state manager. If using fluid layout you will be able to animate stuff that doesn't animate. Like moving uielement out of a grid column to another.

Not sure if this is of any help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文