wpf datagrid rowdetail is cut off

2019-02-26 05:07发布

问题:

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>

回答1:

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.