MaterialDesignInXamlToolkit
MaterialDesignInXamlToolkit copied to clipboard
C# WPF DataGrid column header style error Cannot find source: RelativeSource FindAncestor
Bug explanation
I'm using C# WPF .NET Core 6 also Material Design Theme nuget, I have problem with DataGrid's Column Header Style I have Set a Style for Column Headers of my DataGrid When I'm trying to enter some data into my DataGrid suddenly I get this error in my XAML (Binding failures) :
HorizontalGridLinesBrush DataGridColumnHeader.BorderBrush Brush Cannot find source: RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DataGrid', AncestorLevel='1'.
GridLinesVisibility DataGridColumnHeader.BorderThickness Thickness Cannot find source: RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DataGrid', AncestorLevel='1'.
After a lot of Debugging I found out if I remove this BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}" from My Style <Style x:Key="CenteryHeaderstyle" TargetType="DataGridColumnHeader" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}"> It would be fixed !
https://stackoverflow.com/questions/77435140/c-sharp-wpf-datagrid-column-header-style-error-cannot-find-source-relativesourc
Version
4.9.0
The problem is if I change this "DataGridColumnHeader" I will get "Error 1 null HorizontalGridLinesBrush DataGridColumnHeader.BorderBrush Brush Cannot find source: RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DataGrid', AncestorLevel='1'."
"Error 1 null GridLinesVisibility DataGridColumnHeader.BorderThickness Thickness Cannot find source: RelativeSource FindAncestor, AncestorType='System.Windows.Controls.DataGrid', AncestorLevel='1'."
Could you provide a test repository?
This issue is marked stale because it has been open 30 days with no activity. Remove stale label or update the issue, otherwise it will be closed in 14 days.
Closed due to staleness