Hey. I have a tabcontrol that is bound to an observable collection.
I've tried doing
var tabitem = (TabItem)this.SingleOrDefault(ti => ti.Name == tabname);
tabitem.Focus();
((UserControl)tabitem.Content).Focus();
And it does seem like it focuses on the tabitem, but only on a btn in the header of the tabitem, not on the content. the tabitem content is another usercontrol.
How can I change the focus to the content, so that the tab actually is selected and not just the tabheader
I know of tabcontrol.selecteditem, but Iøm not really sure how I would implement this as the observablecollection is actually a class that i've called ObservableTabCollection, that just implements observable collection.
My solution became to simply create a method on the observabletabcollection that would associate the tabcontrol with the observabletabcollection
public TabControl AssociatedTabControl;
internal void BindToTabControl(TabControl TabCtrl)
{
AssociatedTabControl = TabCtrl;
}
and then inside a method call
if (AssociatedTabControl != null) AssociatedTabControl.SelectedItem = tabitem;