I Have a DocumentContentHost with several Pane.
I Manage the TabGroupPane With TabGroupPane_SelectionChanged :
private void TGPane_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int sel = TGPane.SelectedIndex;
if (sel == 0) { Edit first pane ].
if (sel == 1) { Edit second pane ].
But , When I change a ListBox or Combobox of my Pane , I perform all the time the tabgrouppane_Selectionchanged :
How to avoid to repeat the tabgrouppane_selectionchanged.
Thank you CaisseOdeV
Thank you Caisseodev
Causing a first chance exception for a type check probably isn't the best approach. You can just check if the OriginalSource is a TabGroupPane. e.g.
if (!(e.OriginalSource is TabGroupPane)) return;
thank you for the explanation. I Have Understood
For Test , I Write that anf it work well :
try
{ TabGroupPane Tgp = (TabGroupPane)(e.OriginalSource);
if (Tgp == null) return;
}
catch (Exception) { return; }
But i thing that a best methode existe ?
Cordialement Caisseodev
TabGroupPane is a derived TabControl which is a derived Selector and it is that that defines the SelectionChanged event. The SelectionChanged event is a routed bubble event so if it is not handled for an element within (such as your listbox/combobox within a tab) then it will bubble up to the TabControl. You need to check the e.OriginalSource to see which object is actually raising the SelectionChanged and in this case ignore it unless it is the TabGroupPane.