WPF数据网格rowdetail被切断 [英] wpf datagrid rowdetail is cut off
问题描述
我有一个WPF的DataGrid改变rowdetails的DataTemplate基础上的一列的组合框选择(操作列的)。其中rowdetails模板的大,提供的数据网格的空间不能充分发挥rowdetails,因此细节被切断。如果您尝试向下滚动下一个记录显示,该rowdetails不是从当前记录的其余部分。换句话说,它不部分地穿过一个记录滚动。
示例: (看到农田底部切断,但如果您单击滚动条按钮,一旦下一条记录出现,所有该记录的上移是不可见的其他记录不可见的。的)
问:
有没有办法让DataGrid的滚动功能移动不只是记录到记录,但显示的超大rowdetails?
解决方法:
按照下面接受的答案,我增加了以下到我的DataGrid的风格:
<风格的TargetType ={X:类型的DataGrid}>
< setter属性=VirtualizingPanel.ScrollUnitVALUE =像素/>
< /样式和GT;
这可能会帮助你,虽然它的队伍,你使用.NET 4.5:
的<一个href="http://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingpanel.scrollunit.aspx"相对=nofollow> VirtualizingPanel.ScrollUnit 附加属性可以让你改变你的的DataGrid
的滚动行为:
获取一个值,该值指示滚动是否被测量为项目 集合或像素。
使用 VirtualizingPanel.ScrollUnit =像素
,而不是项目
应该让你的方式来滚动您后再。
如果您使用的不是4.5,你可能有敲东西了一个的ScrollViewer
在模板中。
I have a WPF datagrid that changes the rowdetails datatemplate based on the combobox selection of one of the columns(action column). One of the rowdetails template is large and the space provided for the datagrid cannot fully display the rowdetails, and therefore the details are cut off. If you try to scroll down the next record is shown, not the rest of the rowdetails from the current record. In other words, it does not scroll partially through a record.
EXAMPLE: (notice the fields cut off at the bottom, there are other records not visible. If you click the scroll bar button once the next record appears and all of this record is moved up and is not visible.)
QUESTION:
Is there a way to get the datagrid scrolling function to move not just record to record, but to display oversized rowdetails?
SOLUTION:
As per accepted answer below, i added the following to my datagrid style:
<Style TargetType="{x:Type DataGrid}">
<Setter Property="VirtualizingPanel.ScrollUnit" Value="Pixel" />
</Style>
This may help you out, although it's contingent on you using .NET 4.5:
The VirtualizingPanel.ScrollUnit attached property will allow you to alter the scrolling behaviour of your DataGrid
:
Gets a value that indicates whether scrolling is measured as items in the collection or as pixels.
Using VirtualizingPanel.ScrollUnit="Pixel"
, rather than Item
should allow you to scroll in the way you're after.
If you aren't using 4.5, you might have to knock something up with a ScrollViewer
in the template.
这篇关于WPF数据网格rowdetail被切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!