-
-
SelectionChanged Event of Tab Control Firing on Form Load
by azamsharp on 11/4/2008 12:38:04 PM
-
I am developing a WPF application and for some reason whenever the form is loaded the SelectionChanged event of the TabControl gets fired. How can I stop this from happening?
-
// attaching the event in the Form constructor
documentTabs.SelectionChanged += new SelectionChangedEventHandler(documentTabs_SelectionChanged);
documentTabs.SelectedIndex = -1;
void documentTabs_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// get the selected item
TabItem item = documentTabs.SelectedItem as TabItem;
if (item == null) return;
MessageBox.Show(item.Header.ToString());
}
-
Refactor it!
Please log in to refactor the code!
Login