This project is read-only.

SelectionChanged event fires multiple times as TAB selection changed.

Apr 26, 2011 at 2:05 PM


I need to track the selected tab changed event. I have tried with SelectionChanged event handler.

But I found this event is firing more than one time as I change the tab selection.

It is also firing at time of tabclosing event.

Can you please help me to handle the tab change event properly.

Please let me know how to achieve this. It is very critical to me to figure it out properly.

Thanks in advance.

Apr 27, 2011 at 1:28 PM

Yeah, the selected tab must be quickly cycled through all of the tabs in order to force WPF to render the graphics and thus enabling "screenshots" of the tab's content to be taken---thus it ends up firing more than you would expect.

Can you please provide me with more details of what you are trying to do?  So you want to react to the SelectionChanged event---but what specific actions are you wanting to take when a tab is selected (or unselected)?

Apr 28, 2011 at 6:07 AM

Hi adajos,

Thnaks for your reply. You stated exactly what I am suspected. I have also tried out the TabItem Event doFocus. Unfortunately results same.

Here for each tab a user control is loaded showing some information and On selecting tabs I need to update some data on the parent window.

For these reasons I have to react with the SelectionChanged or DoFocus event.

Note :  Can the screenshots can be taken only at the begining. i.e only at the load time. And need not to update with the every time when any tab is selected.

I am currently stuck to this problem only and holding my project for a bit.

I have tried with the open source but not finding any quick solution. Waiting for your reply.

Apr 28, 2011 at 1:59 PM


So the reason why the screenshots are taken any time another tab is selected is for the tooltips you see when you hover over a tab header.  To make sure that an out-of-date screenshot is not shown in those tooltips everytime you change the tab all the other tabs are cycled through and their screenshots are updated.

Luckily this is open source so you can hack the code up any way you if you don't care about the tooltips being up-to-date you should be able to simply do this:

In FabTabControl comment out every line in OnSelectionChanged() with the exception of base.OnSelectionChanged(e).  So, you could turn the tooltips off by setting the ShowToolTipImages to false on the FabTabControl in your XAML.  However, I think that if you do this when you go the Content tab it will also be out of date---so you may need to have some explicit check added into the FabTabControl to see if the currently selected tab is the content tab and THEN call the code in OnSelectionChanged that you just commented out.

Or you could turn the Content tab off altogether--but I'm not sure which specific FabTab functionality you are wanting, and that's the most common feature that people use I think.

Hope that helps.