how to get previous tab item in SelectionChanged of TabControl

2 posts, 0 answers
  1. Swathi
    Swathi avatar
    16 posts
    Member since:
    Dec 2010

    Posted 21 Dec 2010 Link to this post

    Hi ,
       I need previous tab name when i am switching to new tab in Tab SelectionChanged event.
       Suggest me how can i get that

  2. Petar Mladenov
    Petar Mladenov avatar
    2882 posts

    Posted 23 Dec 2010 Link to this post

    Hi Swathi,

    You cannot access the RadTabItem you have selected last by the EventArgs in a TabControl event handlers. You have to implement your own custom logic like so:
    public partial class MainWindow : Window
           private RadTabItem lastSelectedItem;
           public MainWindow()
               lastSelectedItem = null;
           private void tabControl_SelectionChanged(object sender, RoutedEventArgs e)
               if (lastSelectedItem != null)
                   MessageBox.Show("Last Selected item: " + lastSelectedItem.Header.ToString());
               lastSelectedItem = this.tabControl.SelectedItem as RadTabItem;
    Hope this fits in your scenario. Feel free to ask if you need further assistance.

    Best wishes,
    Petar Mladenov
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for WPF
  3. DevCraft R3 2016 release webinar banner
Back to Top