I am working on an application where I have a ContentControl, and I need to know when the content changes. My initial thought was to add an event handler for the ContentChanged event. I came to find out that the ContentControl does not fire a ContentChanged event.
My solution was to create a control derived from content control that fires that particular event. It is working quite nicely, so I thought I would share. I hope it helps you out. It’s a small amount of code, but it does the trick.
public class ChangeAwareContentControl : ContentControl
private static void OnContentChanged(DependencyObject d,
ChangeAwareContentControl mcc = d as ChangeAwareContentControl;
if (mcc.ContentChanged != null)
= new DependencyPropertyChangedEventArgs(
ContentProperty, e.OldValue, e.NewValue);
public event DependencyPropertyChangedEventHandler ContentChanged;
Here is how you use it in xaml.