WPF:使用 GridSplitter 触发内容调整大小
我试图强制网格/扩展器重新评估它是否需要滚动条,因为它显示为空。
我正在使用此布局:
<Grid>
<toolstrip /> <!-- fixed height row -->
<Scrollviewer> <!-- * height -->
<Grid> <!-- all rows are 'Auto' height -->
<Expander />
<Expander> <!-- this one stretches far too high -->
<WPF Toolkit: DataGrid />
<Expander>
<GridSplitter/>
<Expander />
<Grid>
</Scrollviewer>
<stackpanel /> <!-- fixed height row -->
<Grid>
初始化窗口时,DataGrid(WPF 工具包)绑定到一个属性。 通过一些调查,我意识到当窗口初始化时,GridView 中的列以大约 10 像素宽开始,然后添加内容,然后根据 XAML 中的大小调整它们的大小(全部使用星形宽度) - 例如:2*)。 这会导致网格大小调整为窗口显示时所需高度的大约 6 倍,然后它不会弹回,查看窗口底部内容的唯一方法是滚动或移动 GridSplitter回到原来的位置并调整窗口大小。 我还没有设置任何东西的 VerticalAlignment 属性。
到目前为止,我已经在问题扩展器上尝试了以下所有称为 InvalidateArrange()、InvalidateVisual();、InvalidateMeasure() 和 UpdateLayout() 的方法,以及在网格上尝试了 InvalidateArrange()、InvalidateScrollInfo()、InvalidateVisual() 和 UpdateLayout() 的方法在它之上,但它不会退缩。
有什么方法可以强制它不强制 DataGrid 中列的宽度吗?
I'm trying to force a grid/expander to reevaluate whether it needs a scrollbar, as it's showing emptiness.
I'm using this layout:
<Grid>
<toolstrip /> <!-- fixed height row -->
<Scrollviewer> <!-- * height -->
<Grid> <!-- all rows are 'Auto' height -->
<Expander />
<Expander> <!-- this one stretches far too high -->
<WPF Toolkit: DataGrid />
<Expander>
<GridSplitter/>
<Expander />
<Grid>
</Scrollviewer>
<stackpanel /> <!-- fixed height row -->
<Grid>
The DataGrid (WPF Toolkit) is bound to a property when the Window is initialized. Through some investigating, I've realized that when the window is initialized, the columns in the GridView start at about 10 pixels wide, then the content is added, then they're resized based on the sizes in the XAML (All using star widths - eg: 2*). This causes the grid to resize to about 6 times the height it needs to be as the window is showing, then it doesn't spring back and the only way to see what's at the bottom of the window is to either scroll or move the GridSplitter back up to where it should be and resize the Window. I haven't set the VerticalAlignment properties on anything.
So far I've tried all of the following called InvalidateArrange(), InvalidateVisual();, InvalidateMeasure() and UpdateLayout() on the problem expander and InvalidateArrange(), InvalidateScrollInfo(), InvalidateVisual() and UpdateLayout() on the Grid above it but it won't shrink back.
Is there any way I can force it to short of forcing the width of the columns in the DataGrid?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试在 ScrollViewer 上设置这些属性:
如果这不起作用,您能否提供更准确的 XAML 表示。 此外,深入了解 ScrollViewer 可能会有所帮助。
Try setting these properties on the ScrollViewer:
If that doesn't work, can you provide a more exact representation of your XAML. Also, taking a look at the ScrollViewer in depth may help.