调整网格行/列大小时防止重绘窗口
WPF 网格容器,具有多行/列,并在各部分中加载用户控件。
某些行/列通过根据按钮单击设置列/行宽度(从 0 到 125* 或固定值)来展开/折叠。
简单的示例代码:
If colgrdFolder1.Width.Value Then
Me.Width = Me.Width - colgrdFolder1.ActualHeight
colgrdFolder1.Width = New GridLength(0)
Else
Me.Width = Me.Width + 150
colgrdFolder1.Width = New GridLength(150)
End If
这可以工作,但是当父级调整大小时,它会随着列/行的设置而闪烁。当父宽度第一次增加时,您可以看到网格大小调整,然后当设置新的 colWidth 时,它再次调整大小(并闪烁)。
是否没有属性/方法可以冻结窗口/防止重绘,直到调整大小完成?
WPF grid container, with multiple rows/columns with usercontrols loaded in the sections.
Some rows/columns are expanded/collapsed by setting the Column/Row width (from 0 to 125* or a fixed value), based upon a button click.
Simple example code:
If colgrdFolder1.Width.Value Then
Me.Width = Me.Width - colgrdFolder1.ActualHeight
colgrdFolder1.Width = New GridLength(0)
Else
Me.Width = Me.Width + 150
colgrdFolder1.Width = New GridLength(150)
End If
This works, but when the parent resizes, it flashes as the column/row is set. When the parent Width is first increased you can see the grid resize and then when the new colWidth is set, it resizes (and flashes) again.
Is there not a property/method to freeze the window/prevent redraws until the resize is complete?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为有 BeginInit() 和 EndInit() 方法,应该做你想做的事(防止重绘),但根据我的经验,它们并没有真正起作用(也许我错误地使用了它们)。
我不知道还有什么其他方法可以防止重绘,也许 WPF 方面的专家可以提供更多信息...
I think there are BeginInit() and EndInit() methods, that should do what you want (prevent redraw), but in my experience they haven't really worked (maybe I have used them incorrectly).
I don't know of any other way of preventing redraw, perhaps someone who is more of an expert in WPF can shed some more light...