I think you should check SelectionChange.AddedItems
and SelectionChange.RemovedItems
to find the difference between these to firings. I guess that when you select a page, SelectionChange.RemovedItems==0
while when you click on a tabItem to select it, SelectionChange.RemovedItems==1
. if so just write:
if (SelectionChange.RemovedItems==0)
return;
Edit1: Please see the first comment.
Edit 2
void tablcontrol_SelectionChange(object sender, SelectionChangedEventArgs e)
{
if (e.RemovedItems.Count == 0)
{
// I guess this is the event that happens when a page is selected
// in this case just a TabItem is added to the selection
// and nothing is removed, so do nothing
return;
}
// if you are here, it means that this is another selection changed event
// so Perform those tasks that you mentioned in your question
}