In CM using WPF and the tab control for an MDI style UI, I have an intermittent issue where a tab item does not receive the focus when I activate it. Before I used CM I built my own framework for the MDI and tab control and to solve the problem
before I used the following statement.
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, (ThreadStart)(() => tabItem.Focus()));
First, does anyone know why this happens? Why the tab item activates without receiving focus? Also, where do I put the above code?
I tried to put it on the activate processed event and the content control on the tabitem does not get a reference to its parent so I never get a referrence to the tabitem.
void ShellViewModel_ActivationProcessed(object sender, ActivationProcessedEventArgs e)
var viewModel = e.Item as IViewAware;
if (viewModel != null)
var view = viewModel.GetView() as DependencyObject;
if (view != null)
var tabItem = UIHelper.FindVisualParent(view);
if (tabItem != null)
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.SystemIdle, (ThreadStart) (() => tabItem.Focus()));
Any help would be appreciated.
I am using the latest version of CM.