Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# WPF DataGrid column header style error Cannot find source: RelativeSource FindAncestor #3362

Closed
mojtabahakimian opened this issue Nov 7, 2023 · 4 comments
Assignees
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.

Comments

@mojtabahakimian
Copy link

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

@mojtabahakimian mojtabahakimian added bug evaluation required Items is pending review or evaluation by the team labels Nov 7, 2023
@mojtabahakimian
Copy link
Author

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'."

@MichelMichels
Copy link
Member

Could you provide a test repository?

@MichelMichels MichelMichels added Waiting on feedback Additional information is needed. Stale items with this label may be closed. and removed evaluation required Items is pending review or evaluation by the team labels Mar 31, 2024
@MichelMichels MichelMichels self-assigned this Mar 31, 2024
Copy link
Contributor

github-actions bot commented May 1, 2024

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.

@github-actions github-actions bot added the Stale Issues and PRs that have not had activity for a while are marked with this label. label May 1, 2024
@MichelMichels
Copy link
Member

Closed due to staleness

@MichelMichels MichelMichels closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.
Projects
None yet
Development

No branches or pull requests

2 participants