Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a "All Children loaded" event in WPF

Tags:

c#

.net

wpf

I am listening for the loaded event of a Page. That event fires first and then all the children fire their load event. I need an event that fires when ALL the children have loaded. Does that exist?

like image 320
Shaun Bowe Avatar asked Feb 19 '09 21:02

Shaun Bowe


3 Answers

I hear you. I also am missing an out of the box solution in WPF for this.

Sometimes you want some code to be executed after all the child controls are loaded.

Put this in the constructor of the parent control

Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => {code that should be executed after all children are loaded} ));

Helped me a few times till now.

like image 68
buckley Avatar answered Nov 01 '22 09:11

buckley


Loaded is the event that fires after all children have been Initialized. There is no AfterLoad event as far as I know. If you can, move the children's logic to the Initialized event, and then Loaded will occur after they have all been initialized.

See MSDN - Object Lifetime Events.

like image 32
configurator Avatar answered Nov 01 '22 09:11

configurator


You can also use the event: ContentRendered.

http://msdn.microsoft.com/en-us/library/ms748948.aspx#Window_Lifetime_Events

like image 3
Rover Avatar answered Nov 01 '22 08:11

Rover