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

Inopportune switching tabs with arrow keys

2 Answers 225 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Philippe
Top achievements
Rank 1
Philippe asked on 01 Jul 2011, 05:25 PM
Hi,

I have a problem using the control RadTabControl. In my case, a gridview is in one of the tabitem.
When we navigate in the cells of the gridview with the keyboard arrows and we arrived at the last cell, another press on the right key change the active tab of the tabcontrol (instead of doing nothing because it's the last cell).

With the source code below, you could reproduce the bug with the following steps :
1. Go to the tab "Tab2" containing the Gridview
2. Select the last column of a row
3. Press right arrows key
4. You could now navigate throught the tabs using arrows :(

How can I prevent this?

The xaml code used is quite simple :
<Window x:Class="TestTabs.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" Title="GlobalFund" Height="1024" Width="1280"
        WindowState="Maximized" WindowStartupLocation="CenterScreen">
    <Window.Resources>
        <ResourceDictionary Source="MainWindowResources.xaml" />
    </Window.Resources>
    <telerik:RadTabControl >
        <telerik:RadTabItem Header="Tab1" />
        <telerik:RadTabItem Header="Tab2" >
            <Controls:RadGridView x:Name="SelectedAttributes" AutoGenerateColumns="True" RowIndicatorVisibility="Collapsed">
            </Controls:RadGridView>
        </telerik:RadTabItem>
        <telerik:RadTabItem Header="Tab3">
        </telerik:RadTabItem>
        <telerik:RadTabItem Header="Tab4" />
    </telerik:RadTabControl>
</Window>


I would like to join you the zipped solution but I don't know why but there is no "Attach your file" link in the wpf forum (but it is in silverlight one) :(

An advice?

Thank you for your help....

2 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 06 Jul 2011, 04:40 PM
Hi Philippe,

The behavior you have encountered is expected. The way to prevent this is to handle the PreviewKeyDown event of the RadGridView and implement logic that checks these two conditions:
1) If the current cell is the rightmost one and the e.Key==Key.Right
or
2)If the current cell is the leftmost one and the e.key==Key.Left
The set : e.handled = true;
Please let us know if this fits in your scenario. 

All the best,
Petar Mladenov
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Philippe
Top achievements
Rank 1
answered on 06 Jul 2011, 05:22 PM
Thanks a lot for your answer.
It works! but it's not an easy solution for us :(
We will have to add this code to all our radgridviews...
Tags
TabControl
Asked by
Philippe
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Philippe
Top achievements
Rank 1
Share this question
or