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

how to get previous tab item in SelectionChanged of TabControl

1 Answer 740 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Swathi
Top achievements
Rank 1
Swathi asked on 21 Dec 2010, 01:11 PM
Hi ,
   I need previous tab name when i am switching to new tab in Tab SelectionChanged event.
   Suggest me how can i get that

Thanks,
Swathi.

1 Answer, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 23 Dec 2010, 02:39 PM
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()
       {
           InitializeComponent();
           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
Tags
TabControl
Asked by
Swathi
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Share this question
or