MaterialDesignInXamlToolkit icon indicating copy to clipboard operation
MaterialDesignInXamlToolkit copied to clipboard

Binding errors in DataGrid with ColumnVirtualiztion on

Open Miosss opened this issue 4 years ago • 5 comments

When ColumnVirtualization is on, (or both Row and Column virtualization)

EnableColumnVirtualization="True"

Visual Studio Debugger reports many binding errors in following properties, maybe some other as well:

DataGridCell.Foreground
DataGridColumnHeader.BorderThickness
ListSortDirectionIndicator.Visibility, Name='SortDirectionIndicator'
DataGridColumnHeader.BorderBrush

Those binding throw Exceptions, because they refer with RelativeSource to DataGrid or other grid related elements. I guess that this fails during virtualization magic, when elements are detached from visual tree. FallbackValue or TargetNullValue don't mitigate this, as error occurs in RelativeSource, so before they come into play.

Miosss avatar May 18 '21 16:05 Miosss

I have been dealing with the same issue when applying a custom template for the DataGridColumnHeader. After some extensive troubleshooting I've discovered that adding VirtualizingStackPanel.IsVirtualizing="True" to the DataGrid fixes those binding exceptions.

chocominyo avatar Feb 08 '22 19:02 chocominyo

@MaterialDesignInXAML/triage-team can we simply just add VirtualizingStackPanel.IsVirtualizing="True" on MaterialDesignDataGrid style to fix the issue or is it more complicated ?

ElieTaillard avatar Jun 29 '22 08:06 ElieTaillard

@Xaalek can you reproduce the issues mentioned here? There's no git repo attached to this issue so I would hesitate to just add this without verification.

MichelMichels avatar Jun 29 '22 08:06 MichelMichels

@MichelMichels I tried to put EnableColumnVirtualization="True" on a datagrid from the demo app but I don't get any errors

ElieTaillard avatar Jun 29 '22 08:06 ElieTaillard

@Xaalek if we can't reproduce the issues mentioned, I would not change the default value.

MichelMichels avatar Jun 29 '22 09:06 MichelMichels