This is a migrated thread and some comments may be shown as answers.

RadTabControl sets focus to RadComboBox on tabchange

2 Answers 127 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Prashant
Top achievements
Rank 1
Prashant asked on 31 Oct 2019, 04:35 AM

Hi All,

I have tabcontrols with two tabs and each tab has comboboxes. On initial load everything is working as expected but if i change tab automatically focus sets to combobo control. 

I want to prevent auto focus element tab onchange, please see below sample code to reproduce issue.

 

<telerik:RadTabControl>
            <telerik:RadTabItem  Header="Location">
                <telerik:RadTabItem.Content>
                    <StackPanel>
                        <telerik:RadComboBox Width="200" x:Name="item1" Height="50" IsEditable="True"   EmptyText="Select"  >
                            <telerik:RadComboBoxItem Content="Item 1" />
                            <telerik:RadComboBoxItem Content="Item 2" />
                        </telerik:RadComboBox >
                        <telerik:RadComboBox Width="200" x:Name="item2" Height="50" IsEditable="True"  >
                            <telerik:RadComboBoxItem Content="Item 1" />
                            <telerik:RadComboBoxItem Content="Item 2" />
                        </telerik:RadComboBox>
                    </StackPanel>
                </telerik:RadTabItem.Content>
            </telerik:RadTabItem>
            <telerik:RadTabItem Header="Asset Type" >
                <StackPanel>
                    <telerik:RadComboBox Width="200" x:Name="item3" Height="50" IsEditable="True"    EmptyText="Select" >
                        <telerik:RadComboBoxItem Content="Item 1" />
                        <telerik:RadComboBoxItem Content="Item 2" />
                    </telerik:RadComboBox>
                    <telerik:RadComboBox Width="200" x:Name="item4" Height="50" IsEditable="True"  EmptyText="Select" >
                        <telerik:RadComboBoxItem Content="Item 1" />
                        <telerik:RadComboBoxItem Content="Item 2" />
                    </telerik:RadComboBox>
                </StackPanel>
            </telerik:RadTabItem>
        </telerik:RadTabControl>

 

Any help would be appreciated,

Regards,

Prashant 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 01 Nov 2019, 10:01 AM

Hi Prashant,

This is the default behavior of the RadTabControl when switching tabs. What you can try is to subscribe to the SelectionChanged event of the RadTabControl and focus the RadTabItem. You need to wrap it in a dispatcher so that you can prevent the RadComboBox inside, focusing when you focus a control outside the RadTabControl and focus the RadTabItem again.

private void RadTabControl_SelectionChanged(object sender, Telerik.Windows.Controls.RadSelectionChangedEventArgs e)
{
    Dispatcher.BeginInvoke((Action) (()=> {
        (sender as RadTabControl).Focus();
    }),DispatcherPriority.ApplicationIdle);
}

 

Regards,
Dinko
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Prashant
Top achievements
Rank 1
answered on 03 Nov 2019, 11:06 PM

Really appreciate your help Dianko, it's working as expected.

Regards,

Prashant

Tags
TabControl
Asked by
Prashant
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Prashant
Top achievements
Rank 1
Share this question
or