问题描述
我有一个WPF datagrid,根据其中一列(动作列)的组合框选择更改rowdetails datatemplate。其中一个rowdetails模板很大,为datagrid提供的空间不能完全显示rowdetails,因此细节被切断。如果您尝试向下滚动显示下一条记录,而不是当前记录中剩余的rowdetails。换句话说,它不会部分滚动通过记录。 示例:
(注意到底部截断的字段,其他记录不可见如果下一条记录出现后,点击滚动条按钮,所有的记录都向上移动,不可见。)
问题:
有没有办法获得datagrid滚动功能移动不只是记录记录,而是显示超大的行详细信息?
解决方案:
根据以下接受的答案,我将以下内容添加到我的datagrid样式中:
< Style TargetType ={x:Type DataGrid }>
< Setter Property =VirtualizingPanel.ScrollUnitValue =Pixel/>
< / Style>
这可能会帮助你,尽管它取决于你使用.NET 4.5:
附加属性将允许您更改 DataGrid
的滚动行为:
使用 VirtualizingPanel.ScrollUnit =Pixel
而不是项目
应该允许你按照你的方式滚动。
如果你不使用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
:
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 datagrid rowdetail被切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!