Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to get notified when a child is added/removed from a WPF Panel?

Tags:

wpf

I can't find the event that would get fired when a child is added or removed from a WPF panel. Does such an event exist and I am just missing it?

like image 907
AlfredBr Avatar asked Mar 12 '09 18:03

AlfredBr


2 Answers

I couldn't find an event, but you might try the Panel.OnVisualChildrenChanged method.

like image 103
Robert Macnee Avatar answered Sep 22 '22 21:09

Robert Macnee


Alternatively, you could wrap your panel in a UserControl (perhaps called ObservablePanel?), which has an AddChild method that fires an event after adding the item to the panel.

like image 33
Mike Pateras Avatar answered Sep 24 '22 21:09

Mike Pateras