WPF ListView 折叠时仍保留空间
我在 ScrollViewer 中有一个 WPF ListView。
我需要折叠 ListView,我正在尝试使用此代码(非常简单):
this.myListView.Visibility = Visibility.Collapsed;
问题是 ListView 似乎在折叠时保留空间 - 它消失了,但 ScrollViewer 没有相应地调整大小。
我缺少什么吗?
任何帮助表示赞赏
I have a WPF ListView within a ScrollViewer.
I need to collapse the ListView and I am trying withthis code (pretty striaghtoforward):
this.myListView.Visibility = Visibility.Collapsed;
Problem is the ListView seems to be reserving the space even when collapsed - it disappears but the ScrollViewer doesn't accordingly resize.
Anything I am missing?
Any Help appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能的原因可能是 ScrollViewer 默认显示其垂直 ScrollBar。
尝试将 ScrollViewer.VerticalScrollBarVisibility 设置为 自动。
你可以写这样的内容:
我希望它有帮助。
Possible reason could be that ScrollViewer by default shows its vertical ScrollBar.
Try to set ScrollViewer.VerticalScrollBarVisibility to auto.
You can write something like this:
I hope it helps.
感谢大家的回答 - 我发现全局应用的样式导致了问题!现在解决了。
Thanks to everyone for their answers - I found out that a globally applied style was causing the problem! Solved now.