简体   繁体   中英

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 ). 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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