C# WPF DataGrid column header style error Cannot find source: RelativeSource FindAncestor #3362
Labels
bug
Stale
Issues and PRs that have not had activity for a while are marked with this label.
Waiting on feedback
Additional information is needed. Stale items with this label may be closed.
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 text was updated successfully, but these errors were encountered: