SelectionChanged Event - Get Last Selected RadTabItem

3 posts, 1 answers
  1. Chris Andrews
    Chris Andrews avatar
    41 posts
    Member since:
    Mar 2010

    Posted 23 Jun 2010 Link to this post

    Hello All,

    We are in the process of converting the plain old WPF TabControl with the RadTabControl.  We have a need to get the last tab that was selected before the user clicked a new tab.

    Using the WPF TabControl, in the EventArgs, there was an AddedItems and RemovedItems property.  In the RadTabControl, these do not exist.

    Is there a way to get the user's last selected TabItem using this handler?

    Thanks,
    Chris
  2. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 28 Jun 2010 Link to this post

    Hi Chris Andrews,

    You can use the RadTabControl PreviewSelectionChanged() event handler to get the last selected item:
    private void tabControl1_PreviewSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        IList prevSelectedItems = e.RemovedItems;
        IList newSelectedItems = e.AddedItems;
    }

    I hope this information will help you.

    Sincerely yours,
    Tina Stancheva
    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Chris Andrews
    Chris Andrews avatar
    41 posts
    Member since:
    Mar 2010

    Posted 09 Jul 2010 Link to this post

    Thank you for the info.  I ended up using a different approach one of my co-workers found.  I am handling the SelectionChanged event and casting e as a RadSelectionChangedEventArgs object, which does have the Added and Removed items collection.

    Here is the code snippet for those interested:
    void TabControl_SelectionChanged(object sender, RoutedEventArgs e)
    {
        RadSelectionChangedEventArgs eArgs = e as RadSelectionChangedEventArgs;
        // We now have access to e.AddedItems and e.RemovedItems
    }
Back to Top