MaterialDesignInXamlToolkit
MaterialDesignInXamlToolkit copied to clipboard
Binding errors in DataGrid with ColumnVirtualiztion on
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.
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.
@MaterialDesignInXAML/triage-team can we simply just add VirtualizingStackPanel.IsVirtualizing="True" on MaterialDesignDataGrid style to fix the issue or is it more complicated ?
@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 I tried to put EnableColumnVirtualization="True" on a datagrid from the demo app but I don't get any errors
@Xaalek if we can't reproduce the issues mentioned, I would not change the default value.