views:

84

answers:

2

Hi,

To implement tab based environment in WPF we need to convert our WPF form to user control to accomplish tab based environment, however when doing this, loaded event of user control is called two times.

While searching on the internet other people also pointed this issue. How can we ensure that loaded event is called only one time, because when it is called multiple times initialization of controls happen multiple times.

Thanks

A: 

Set a loaded flag in the event, and, if the flag has already been set, don't do anything.

SLaks
@Slaks; thanks for your suggestion, is this really a genuine issue and loaded event called two times due to tab
Muhammad Akhtar
A: 

Actually, there already is a IsLoaded property, so you can add this line to the beginning of the loaded event handler:

If Me.IsLoaded Then Return
Tony Federer
Never mind, that doesn't work. You'll have to use your own property.
Tony Federer