GetNamedElements and Custom ContentControl

Topics: Bootstrappers & IoC, Conventions, Extensibility
Sep 29, 2012 at 9:24 PM

I have created a custom control derived from ContentControl that is very similar to a HeaderedContentControl, except that it has a Header and a Footer. 

I have used the great extension point provided with GetNamedElements and have created my own func that will add my custom control into the named elements. 

In my custom control - like the HeaderedContentControl - I have a OnHeaderChanged event handler that calls this method and does this:

protected virtual void OnHeaderChanged(object oldHeader, object newHeader) {  base.RemoveLogicalChild(oldHeader);
  base.AddLogicalChild(newHeader);
}

With this code in place, CM loses the conventions/binding in the header. If I comment it out, then everything works.

Is there a way to have CM update its named elements when a change like this happens?

I truly appreciate any help! 

Sep 30, 2012 at 1:05 AM

This was my fault.

I was trying to implement code that wasn't necessary. I was trying to copy what Microsoft was doing in the HeaderedContentControl - the OnHeaderChanged above. I simplified my control and now things work great.