private void OnChildChanged(UIElement oldValue, UIElement newValue) { FrameworkElement oldChildElement = oldValue as FrameworkElement; if (oldChildElement != null) { oldChildElement.DataContext = null; } this.AttachViewModel(); }