简体   繁体   English

WPF的DataGrid的Rowdetail被切断

[英]wpf datagrid rowdetail is cut off

I have a WPF datagrid that changes the rowdetails datatemplate based on the combobox selection of one of the columns( action column ). 我有一个WPF数据网格,它根据列之一( 操作列 )的组合框选择来更改rowdetails数据模板。 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. rowdetails模板之一很大,并且为数据网格提供的空间无法完全显示行详细信息,因此细节被切除。 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? 有没有一种方法可以使datagrid滚动功能不仅移动记录到记录,还显示超大的行详细信息?

SOLUTION: 解:

As per accepted answer below, i added the following to my datagrid style: 根据下面接受的答案,我在我的datagrid样式中添加了以下内容:

<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: 尽管这取决于您使用.NET 4.5的情况,但这可能会对您有所帮助:

The VirtualizingPanel.ScrollUnit attached property will allow you to alter the scrolling behaviour of your DataGrid : 附加的VirtualizingPanel.ScrollUnit属性将允许您更改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. 使用VirtualizingPanel.ScrollUnit="Pixel" ,而不是Item可以让您以所追求的方式滚动。

If you aren't using 4.5, you might have to knock something up with a ScrollViewer in the template. 如果您未使用4.5,则可能必须使用模板中的ScrollViewer进行修改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM