private static void OnGroupChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e) { ForeignKeyGroupContentControl contentControl = sender as ForeignKeyGroupContentControl; if (contentControl != null) { contentControl.UpdateContent(e.NewValue as Group); } }
private static object OnCoerceGroupChanged(DependencyObject o, object newValue) { ForeignKeyGroupContentControl contentControl = o as ForeignKeyGroupContentControl; if (contentControl != null) { Group currentGroup = contentControl.Group; Group newGroup = newValue as Group; bool clearContentTemplate = false; if ((currentGroup != null) && (newGroup != null)) { if ((currentGroup.Level == -1) || (newGroup.Level == -1)) { clearContentTemplate = true; } // The Group is different, must clear the templates else if (currentGroup.GroupBy != newGroup.GroupBy) { clearContentTemplate = true; } } else { // The Group is null or different, must clear the templates clearContentTemplate = true; } if (clearContentTemplate) { contentControl.ClearValue(ContentControl.ContentTemplateProperty); contentControl.ClearValue(ContentControl.ContentTemplateSelectorProperty); } } return(newValue); }