This question is locked. New answers and comments are not allowed.
Hi there, we're experiencing some very strange behaviour with RadTabControl (Q2 2012 SP1 version).
We have a tab control with 4 tabs, when the user clicks the last tab, the first control (a TextBox) inside the tab item content is focussed automatically, which is completely against what we want to happen.
I've had a look at the disassembled source for RadTabControlBase, and it appears there is some code in there (UpdateFocusOnSelectionChange) that does exactly what is happening - the first enabled / visible control inside the new tab content is focussed directly:
protected internal virtual void UpdateFocusOnSelectionChange()
{
if (!this.IsUserInitiatedSelection)
return;
IRadTabItem selectedContainer = this.GetSelectedContainer();
if (selectedContainer == null)
return;
DependencyObject descendant = (DependencyObject) (this.GetFocusedElement() as UIElement);
ContentPresenter currentContentElement = this.GetCurrentContentElement();
bool shouldFocusContent = descendant == null || currentContentElement != null && ParentOfTypeExtensions.IsAncestorOf((DependencyObject) currentContentElement, descendant) || !ParentOfTypeExtensions.IsAncestorOf((DependencyObject) this, descendant);
this.Dispatcher.BeginInvoke((Action) (() =>
{
if (shouldFocusContent)
{
Control local_0 = currentContentElement == null ? (Control) null : ChildrenOfTypeExtensions.GetFirstDescendantOfType<
Control
>((DependencyObject) currentContentElement);
if (local_0 == null)
{
FrameworkElement local_1 = this.SelectedContent as FrameworkElement;
local_0 = local_1 != null ? ChildrenOfTypeExtensions.GetFirstDescendantOfType<
Control
>((DependencyObject) local_1) : (Control) null;
}
if (local_0 == null)
return;
local_0.Focus();
}
else
selectedContainer.Control.Focus();
}));
}
I would like to know if there is a way that I can stop this from happening, and why it's happening in the first place.
Thanks,
Sam