I found 3 ways of getting to the click events for a tab item. Neither seems to work though in all cases. how to handle TabItem single click event in WPF?
- Using _GotFocus event. I tried that first, but if the tab is already in focus, it does not fire. And we are talking about click on tab1, then click on grid inside tab 1. Then click on tab2, then click on grid in tab2. So far events fired. Then when I click on Tab1 again...no events are fired. I was able to go between tab2 and 3 4 or 5 times with no events being fired.
- Click event for tab labels. This seemed to be the most successful of the 3. If you click on a label you the event always fires up. However...what if you don't click on a label. The label does not span the whole tabcontrol box(the one you click to switch). So it's possible to cheat and click on the edges and there goes this idea.
- SelectionChanged event. This one behaved really weird. I would click on all the tabs once and it seemed to work fine. Then I was on Tab3 and clicked on tab2...and I got two events...one for tab2 first then one for tab 3. Then I'd end back on Tab3?
Is there a single solution that works for just switching tabs? I could also be doing something wrong in the above implementations...it's just that this doesn't seem that difficult. I'm not sure what I could be doing wrong...
Thanks in advance.