Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

WPF TabControl's SelectionChanged event handler executing twice..!

$
0
0

Hi, I am having problems with an TabControl's event: SelectionChanged.

the first problem I had was that my event was raised many times, so I Added this to my code:

In my XAML:

<TabControlName="mainTabControl"SelectionChanged="mainTabControl_SelectionChanged">
and in my code Behind:
void mainTabControl_SelectionChanged(object sender,SelectionChangedEventArgs e){if(e.SourceisTabControl){// do some}}

But, then I started having another problem which was because the event was trying to raise when the form wasnt loaded, so I added the following:

void mainTabControl_SelectionChanged(object sender,SelectionChangedEventArgs e){if(e.SourceisTabControl){if(this.IsLoaded){// do some  }}}

But my problem right now is that the FIRST time I try to change of tabItem the event raises TWICE and the selected tabItem remains the same, after doing that the event works as expected.

How Can I solve the last problem? Am I doing something wrong?


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>