Silverlight tabchanged event - tabcontrol
I'm using tab control and I want to handle tabchanged event.
I was trying to use SelectionChanged
event with no luck. It's being fired too many times (after loading tabcontrol, or adding new tab).
I would like to handle th开发者_如何学Gois event only when user navigates between tabs.
I have found solution for WPF (Is there Selected Tab Changed Event in the standard WPF Tab Control) but it's no good for Silverlight. TIA.
Firing "too many times" should not be a problem if you check for an actual change to the SelectedIndex
property in the event.
private int LastSelectedTab = -1;
void tab_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
TabControl tab = sender as TabControl;
if (this.LastSelectedTab != tab.SelectedIndex)
{
this.LastSelectedTab = tab.SelectedIndex;
// Now do your thing...
}
}
精彩评论