dotnet / dotnet/wpf

Binding Error For TabControl

Open
#6,845 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

* .NET Core Version: (e.g. 3.0 Preview1, or daily build number, use `dotnet --info`)
* Windows version: (`winver`)
* Does the bug reproduce also in WPF for .NET Framework 4.8?: Yes/No
* Is this bug related specifically to tooling in Visual Studio (e.g. XAML Designer, Code editing, etc...)? If yes, please file the issue via the instructions [here](https://docs.microsoft.com/visualstudio/ide/how-to-report-a-problem-with-visual-studio?view=vs-2019).
* Security issues and bugs should be reported privately, learn more via our [responsible disclosure guidelines](https://github.com/dotnet/wpf/blob/main/README.md#reporting-security-issues-and-security-bugs).



**Problem description:**
Binding Error on the second TabItem.
I use a DataGrid in a TabControl, and under the two TabItems below the TabControl, add two identical DataGrids. The DataGrid under the first TabItem binds data successfully, but the CheckBox for the header of the first column under the second DataGrid fails.

**Actual behavior:**

System.Windows.Data Error: 4 : Cannot find source for binding with reference 'RelativeSource FindAncestor, AncestorType='BindingTest.MainWindow', AncestorLevel='1''. BindingExpression:Path=OrderViewModel.IsAllOrderSelected; DataItem=null; target element is 'CheckBox' (Name=''); target property is 'IsChecked' (type 'Nullable`1')

**Expected behavior:**

**Minimal repro:**
`





SelectAll










SelectAll





`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.