WPF TabControl selected tab out-of-sync after validation
- Dominant language
- C#
- Stars
- 7.7k
- Forks
- 1.3k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 61
Description
_This issue has been moved from [a ticket on Developer Community](https://developercommunity.visualstudio.com/t/WPF-TabControl-selected-tab-out-of-sync-/10950927)._
---
[severity:It's more difficult to complete my work]
When using a WPF TabControl, in the event that the bound model reverts/does-not-accept the selection of a new tab, the selected header of the TabControl becomes out-of-sync. i.e. the model matches the `TabControl.SelectedItem`, but the `TabControl.SelectedIndex` is out-of-sync (left at the last clicked-on tab header).
This [minimum reproduceable sample](https://aka.ms/dc/file?name=B86d10911c03f42bf85b41c659a58d4f2638906911780433697_TabControlBug.zip&tid=86d10911c03f42bf85b41c659a58d4f2638906911780433697) demonstrates the issue we are seeing.
For context, below is a screenshot from the attached sample application (that targets net8.0-windows).

It binds the `TabControl.SelectedItem` property to the `MainWindowViewModel.SelectedTab` property using a TwoWay binding. When the 'Deny tab change' checkbox is checked (default), `MainWindowViewModel.SelectedTab` does not update its backing field in order to represent the model validating the selection and choosing to prevent it.
Steps to reproduce the TabControl's `SelectedItem` and `SelectedIndex` properties becoming out-of-sync:
1) starting the applicaiton, the first tab (tab 'A') is selected.
2) With the 'Deny tab change' checkbox checked, click on tab 'B'.
3) The `MainWindowViewModel.SelectedTab` does not change its value from 'A', but still raises a property changed event.
4) The `SelectedItem` and `SelectedIndex` properties of the TabControl become mis-matched, 'A' and 1 respectively. I.e. it shows the 'Content of A' in the content area of the control (which is expected), but the visibly selected tab header is 'B' (unexpected)
A similar out-of-sync issue is seen if TwoWay binding the view model to the `SelectedIndex` instead.
---
### Original Comments
#### Feedback Bot on 14/8/2025, 09:16 AM:
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.
Contributor guide
Assessment
This issue has not been assessed yet.