wpf datagrid rowdetail 被切断 [英] wpf datagrid rowdetail is cut off

查看:25
本文介绍了wpf datagrid rowdetail 被切断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WPF 数据网格,它根据列(操作列)的组合框选择更改 rowdetails 数据模板.其中一个rowdetails模板较大,为datagrid提供的空间无法完全显示rowdetails,因此细节被截断.如果您尝试向下滚动,则会显示下一条记录,而不是当前记录的其余行详细信息.换句话说,它不会部分滚动记录.

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.

示例:(请注意底部被截断的字段,还有其他记录不可见.如果在下一条记录出现时单击滚动条按钮,并且该记录的所有内容都向上移动并且不可见.)

有没有办法让数据网格滚动功能不仅移动记录到记录,而且显示超大的行详细信息?

Is there a way to get the datagrid scrolling function to move not just record to record, but to display oversized rowdetails?

根据下面接受的答案,我在我的数据网格样式中添加了以下内容:

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>

推荐答案

这可能会对您有所帮助,尽管这取决于您是否使用 .NET 4.5:

This may help you out, although it's contingent on you using .NET 4.5:

VirtualizingPanel.ScrollUnit附加属性将允许您更改 DataGrid 的滚动行为:

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.

使用 VirtualizingPanel.ScrollUnit="Pixel" 而不是 Item 应该允许您按照您想要的方式滚动.

Using VirtualizingPanel.ScrollUnit="Pixel", rather than Item should allow you to scroll in the way you're after.

如果您使用的不是 4.5,则可能需要在模板中使用 ScrollViewer 进行修改.

If you aren't using 4.5, you might have to knock something up with a ScrollViewer in the template.

这篇关于wpf datagrid rowdetail 被切断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆