Reputation: 762
I am trying figure out how cancel this event in Silverlight, sadly I didn't find any useful link with the solution. (I saw some post for wpf which I think are not longer available for Silverlight)
Upvotes: 2
Views: 2259
Reputation: 189437
Here is the bare bones of it:-
bool cancellingTabSelectionChange = false;
private void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (e.RemovedItems.Count > 0 && !cancellingTabSelectionChange)
{
cancellingTabSelectionChange = true;
((TabControl)sender).SelectedItem = e.RemovedItems[0];
cancellingTabSelectionChange = false;
}
}
You would need to add the extra criteria the would allow a change to take place since the above code would always block a change of tab.
Upvotes: 4
Reputation: 352
As i know there is not straight way to cancel it. You can disable control if dont want change tab, or set selectedtab to which you want after selectionchanged fired.
private void tabControl1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
tabControl1.SelectedIndex = [index of tab]
}
Upvotes: 0