Inopportune switching tabs with arrow keys

3 posts, 0 answers
  1. Philippe
    Philippe avatar
    3 posts
    Member since:
    Apr 2011

    Posted 01 Jul 2011 Link to this post


    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: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">
            <ResourceDictionary Source="MainWindowResources.xaml" />
        <telerik:RadTabControl >
            <telerik:RadTabItem Header="Tab1" />
            <telerik:RadTabItem Header="Tab2" >
                <Controls:RadGridView x:Name="SelectedAttributes" AutoGenerateColumns="True" RowIndicatorVisibility="Collapsed">
            <telerik:RadTabItem Header="Tab3">
            <telerik:RadTabItem Header="Tab4" />

    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. Petar Mladenov
    Petar Mladenov avatar
    3154 posts

    Posted 06 Jul 2011 Link to this post

    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
    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!

  3. Philippe
    Philippe avatar
    3 posts
    Member since:
    Apr 2011

    Posted 06 Jul 2011 Link to this post

    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...
Back to Top