RadTabControl / RadTabItem events.

9 posts, 0 answers
  1. Allan
    Allan avatar
    24 posts
    Member since:
    Jun 2009

    Posted 11 Jun 2009 Link to this post

    I have a small RadTabControl that has 3 RadTabItems as children. I've tried setting up the GetFocus events on the RadTabItem in both XAML and in code, but they do not fire. Has anyone else seen this issue?

    Also, I tried to use the RadTabControl.SelectionChanged event as a work around, but that fires when the control loads, not just when the user changes selection so it didn't help.
  2. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 12 Jun 2009 Link to this post

    Hi Allan,

    I assume that you are using the mouse to navigate between items. Let's say you are at Item1 and you click Item2. GotFocus does not fire in this case. What should be focused is the Content of Item2 (something that does not happen in the current version). The next time you click the header of Item2 is when Item2 gets focused. If you pay closer attention to the tabs inside Internet Explorer, you will experience the same behavior.

    The SelectionChanged event does fire when the control loads. The reason for this is because initially the SelectedIndex property of RadTabControl is set to -1, and as soon as the control loads the property is set to the first index in the collection [0], unless of course you have set a different index or item.

    I have created a sample app demonstrating the events that get fired while interacting with RadTabControl.



    Have a look at it and if you have any questions or comments, let us know.

    Kind regards,
    Kiril Stanoev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Arnstein
    Arnstein avatar
    36 posts
    Member since:
    Oct 2012

    Posted 13 Sep 2010 Link to this post

    "What should be focused is the Content of Item2 (something that does not happen in the current version)"

    This is still an issue right?

    I've got one tabcontrol with 3 tabitems. The first input control in the first tabitem is a RadComboBox, the second tabitem has a RadMaskedTextBox and the third tabitem a CheckBox. When I switch tab the first inputcontrol should get foucs, but this is only the case for the tabitem with a checkbox. The other two tabitems are not setting focus on any control. If I replace the MaskedTextBox with a checkbox the focus is set on the control . With a standard TabControl the foucs is set correctly for all 3 tabitems.

    The event RadTabControl_PreviewGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) is only firing for the tabitem with a checkbox as the first input element when using RabTabControl, but with a standard TabControl it's fired on all 3 tabitems.
  5. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 16 Sep 2010 Link to this post

    Hello Arnstein,

    With which version are you testing? I am testing with 2010.2.827.35 and you can see the outcome recorded here. Also please find attached my test application. Have a look at it and let me know if I am doing anything wrong.

    All the best,
    Kiril Stanoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. Arnstein
    Arnstein avatar
    36 posts
    Member since:
    Oct 2012

    Posted 17 Sep 2010 Link to this post

    Thanks for your reply, I'm testing with 2010.2.806.40 and your test app works correctly.
    It seems to me that the problem occurs when the first element in the TabItem is not an input control. If you add a label before the RadComboBox or the RadMaskedTextBox focus will not be set, and RadTabControl_PreviewGotKeyboardFocus is not called. If I replace the RadTabControl with a TabControl focus is set correctly on the first input control.

    <Controls:RadTabItem Header="Item 1">
                    <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="200">
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        
                        <Label Content="Test"></Label>
                        <Controls1:RadMaskedTextBox Grid.Row="1" Value="1234" />
                    </Grid>
                </Controls:RadTabItem>
  7. Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 22 Sep 2010 Link to this post

    Hello Arnstein,

     You can attach the Label control to an Imput control using it's Target proeprty. I believe this will prevent the behaviour you've mentioned.
    Target="{Binding ElementName=maskTextBox}"

    Regards,
    Miro Miroslavov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Arnstein
    Arnstein avatar
    36 posts
    Member since:
    Oct 2012

    Posted 22 Sep 2010 Link to this post

    We're already using Target from the labels in order to support access keys. I also tried this with the test app, and setting a target from the label didn't have any noticeable affect on setting focus to the maskedtextbox. Any other suggestions? As mentioned earlier, this works out of the box with a System.Windows.Control.TabControl.

    Arnstein
  9. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1511 posts

    Posted 27 Sep 2010 Link to this post

    Hi Arnstein,

    We will investigate the reason why both tab controls behave differently.
    Now, if you have the following definition of a RadTabItem:

    <telerik:RadTabItem Header="Item 1">
        <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="200">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Label Content="_Test" Target="{Binding ElementName=maskedTextBox}" />
            <telerik:RadMaskedTextBox x:Name="maskedTextBox" Grid.Row="1" Value="1234" />
        </Grid>
    </telerik:RadTabItem>

    When you click "Item 1", RadTabControl will not focus the RadMaskedTextBox, while MS TabControl will do. We will investigate this scenario to see whether it is appropriate to supported it.However if you press ALT + T (the access key for the Label), RadMaskedTextBox will be focused in both cases. If you want the RadMaskedTextBox to be focused immediately after clicking "Item 1", a workaround is simply to put RadMaskedTextBox before the Label.

    <telerik:RadTabItem Header="Item 1">
        <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="200">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <telerik:RadMaskedTextBox x:Name="maskedTextBox" Grid.Row="1" Value="1234" />
            <Label Content="_Test" Target="{Binding ElementName=maskedTextBox}" />
        </Grid>
    </telerik:RadTabItem>

    Visually they will be rendered as the previous snippet but RadMaskedTextBox will be focused immediately.
    Let me know if this workaround is acceptable while we investigate this behavior.

    I've also added this item in our public issue tracking system under the name "TabControl: Focus behaves differently between RadTabControl and MS TabControl when selecting a TabItem" and it will be available for tracking and voting tomorrow the latest.

    Greetings,
    Kiril Stanoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Arnstein
    Arnstein avatar
    36 posts
    Member since:
    Oct 2012

    Posted 28 Sep 2010 Link to this post

    Thank you Kiril. I can live with that workaround and hopefully the issue will be looked into later on.

    Arnstein
Back to Top
UI for WPF is Visual Studio 2017 Ready