Two times loading event triggering

Two times loading event triggering

23 Feb 2010 01:02:51
Dear Guys, I have a series issues in WPF application. Let's say i have a WPF desktop application all are build by soft code, method calling also we have define in the database.Since i have so many user controls which are finally load into the tab control. when user the click the menu items. now When i click a menu to load a user control(Report) in to the tab, user control load event firing two times. this is happening to all user controls. i don't know why this happening? Please help me on this. Note:.NET 3.5 Framework SP1 and WPF application. Thank you
Gold   Boarder
Posts: 156
From 03-Jun-2009
You're Points: 1106
Bookmark
Re:Two times loading event triggering23 Feb 2010 01:02:51
Hi Finally i got what is the wrong,actually WPF event are working like routed event so when you add your user control in your it's trigger event and second time normal user control load. The resolution Use the flag value to prevent multiple times load event raise in your load event. [b]VB.NET[/b] [color=#0000FF]dim IsBuild as boolean=false Private Sub UserControl_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) If IsBuild = True Then Return End If ' action here IsBuild = True End Sub[/color] [b]C#[/b] [color=#0000FF] bool IsBuild = false; private void UserControl_Loaded(System.Object sender, System.Windows.RoutedEventArgs e) { if (IsBuild == true) { return; } // action here IsBuild = true; } [/color] Thank you
RRaveen
Gold  Boarder
Posts: 156
From 03-Jun-2009
You're Points: 1106
Bookmark
^ Scroll to Top