动画 WPF DataGrid 行详细信息
任何人都可以帮助我在打开和关闭时对 WPF DataGrid 行详细信息进行动画处理(例如,当选择行时,幻灯片像手风琴一样打开,而当未选择行时,幻灯片会关闭)?我需要一个简单的概念证明。
预先感谢您的帮助:)
Can anyone help me animating the WPF DataGrid row details when it's opened and closed (e.g. slides open like an accordion when the row selected and slides close when the row is not selected)? I need a simple proof of concept.
Thanks in advance for your help :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
冗长但有效:
编辑:通过在
RowStyle
中手动处理DetailsVisibility
,返回动画现在也可以工作。请注意,一旦细节折叠,DataGrid 的高度就不会缩小,这可能会有点问题。这是 VirtualizingStackPanel 的一个已知问题,如果您负担得起,您可以将 DataGrid.ItemsPanel 更改为普通 StackPanel(如果您有大量数据,这将大大减慢应用程序的速度,因为每一行将立即创建,即使不可见)。
另外:按 Ctrl + A 非常有趣。
Verbose but works:
Edit: By taking care of the
DetailsVisibility
manually in theRowStyle
the return animation now works too.Note that the DataGrid's height does not shrink back once the details are collapsed, which might be a bit problematic. This is a known problem of the VirtualizingStackPanel, if you can afford it you could change the
DataGrid.ItemsPanel
to a normal StackPanel (If you have a lot of data this will greatly slow down the application since every row will be created right away, even if not visible).Also: Pressing Ctrl + A is great fun.