I have a data grid with a scroll and virtualization. Everything else is fine except that there's a possibility for extra 1-23 pixels to scroll to the bottom:
我有一个带滚动和虚拟化的数据网格。其他的都没问题,除了有可能需要额外的1-23像素滚动到底部:
I have a data grid, a custom styled scrollbar on the right and then I have a splitter on the bottom and the problem is that there is empty space between the splitter and grid, which itself is fine (as you can resize the splitter and have more empty space), but the scrollbar is now larger than it needs to be, which causes problems elsewhere. How can I make sure that the scrollbar is exactly "as tall as the content".
我有一个数据网格,自定义样式右边的滚动条,然后我有一个分离器底部,问题是,有分流和网格之间的空白,这本身是好(可以调整分离器和有更多的空间),但滚动条是现在超过需要,这导致其他问题。如何确保滚动条与内容一样高?
I don't want it to scroll to empty places, because I have code elsewhere which reads the scroll position and multiplies by the row height to determine where we are at, and it bugs as soon as you exceed the scrollable area.
我不希望它滚动到空位置,因为我有代码在其他地方读取滚动位置并乘以行高度来确定我们的位置,一旦超出可滚动区域,它就会出错。
The data grid looks like:
数据网格如下:
<DataGrid CanUserSortColumns="False"
CanUserAddRows="False"
CanUserDeleteRows="False"
CanUserResizeColumns="True"
CanUserReorderColumns="True"
SelectionUnit="FullRow"
ScrollViewer.CanContentScroll="True"
SelectionMode="Single"
HeadersVisibility="Column"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling"
AutoGenerateColumns="False" />
Update: I think I know the reason. Because I use virtualization, it scrolls by one row (not by pixels), thus it won't allow me to scroll so that rows are partially visible. It always scroll by the height of a row (in my case 24 units). Now, if I move grid splitter and make the last row to be only partially visible, it correctly shows the scrollbar, but the problem is that it will scroll 24 units and thus showing empty space in the bottom.
更新:我想我知道原因。因为我使用虚拟化,所以它只滚动一行(而不是像素),因此它不允许我滚动,这样行部分可见。它总是按一行的高度滚动(在我的情况下是24个单位)。现在,如果我移动grid splitter并使最后一行仅部分可见,它会正确地显示滚动条,但是问题是它会滚动24个单元,从而在底部显示空的空间。
Coming to realize that, I'm not so sure this problem can be even fixed. I just need to edit the code elsewhere to figure out if there has been exceeding scrolling, and if so, I'll "crop and ignore" the last 1-23 units of scrolling.
意识到这一点,我不确定这个问题是否可以解决。我只需要编辑其他地方的代码,以确定是否有超过滚动的内容,如果有,我将“裁剪并忽略”滚动的最后1-23个单元。
1 个解决方案
#1
0
Please use the property ScrollViewer.VerticalScrollBarVisibility="Auto" on your DataGrid
请使用属性ScrollViewer。在你的DataGrid VerticalScrollBarVisibility =“汽车”
For more information on this property go to http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.verticalscrollbarvisibility.aspx
有关此属性的更多信息,请访问http://msdn.microsoft.com/en- us/library/system.windows.controls.scrollviewer.verticalscrollbarvisity.aspx
#1
0
Please use the property ScrollViewer.VerticalScrollBarVisibility="Auto" on your DataGrid
请使用属性ScrollViewer。在你的DataGrid VerticalScrollBarVisibility =“汽车”
For more information on this property go to http://msdn.microsoft.com/en-us/library/system.windows.controls.scrollviewer.verticalscrollbarvisibility.aspx
有关此属性的更多信息,请访问http://msdn.microsoft.com/en- us/library/system.windows.controls.scrollviewer.verticalscrollbarvisity.aspx