private void UpdateContainerHelper() { // Keep a backup of the template element and initialize the // new helper with it. ItemsControl childrenItemsControl = null; if (_containerHelper != null) { childrenItemsControl = _containerHelper.ChildrenItemsControl; _containerHelper.ClearHelper(); if (_containerHelper is ObjectContainerHelperBase) { // If the actual AdvancedOptionMenu is the default menu for selected object, // remove it. Otherwise, it is a custom menu provided by the user. // This "default" menu is only valid for the SelectedObject[s] case. Otherwise, // it is useless and we must remove it. var defaultAdvancedMenu = (ContextMenu)this.FindResource(PropertyGrid.SelectedObjectAdvancedOptionsMenuKey); if (this.AdvancedOptionsMenu == defaultAdvancedMenu) { this.AdvancedOptionsMenu = null; } } } _containerHelper = new ObjectContainerHelper(this, SelectedObject); ((ObjectContainerHelper)_containerHelper).GenerateProperties(); _containerHelper.ChildrenItemsControl = childrenItemsControl; // Since the template will bind on this property and this property // will be different when the property parent is updated. this.Notify(this.PropertyChanged, () => this.Properties); }