30 May 2012 @ 3:58 AM 

I have have a solution that works really well for those who need to know when a child element is added or removed within their custom control. The ‘Children’ property is actually found by the parser using the “ContentProperty” attribute, and I think it’s inheritable. Anyhow, if you simply put this in your derived class:

new public ObservableCollection<UIElement> Children { get { return _Children; } }
readonly ObservableCollection<UIElement> _Children = new ObservableCollection<UIElement>();

Then all the added elements will now go to this new collection instead! :) All you have to do it listen to the “CollectionChanged” event.

Share
Posted By: James
Last Edit: 17 Jun 2012 @ 04:01 AM

EmailPermalink
Tags
Categories: Coding, Silverlight