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); }
internal PropertyItemBase() { _containerHelper = new ObjectContainerHelper(this, null); this.GotFocus += new RoutedEventHandler(PropertyItemBase_GotFocus); AddHandler(PropertyItemsControl.PreparePropertyItemEvent, new PropertyItemEventHandler(OnPreparePropertyItemInternal)); AddHandler(PropertyItemsControl.ClearPropertyItemEvent, new PropertyItemEventHandler(OnClearPropertyItemInternal)); }
public override void ClearChildrenPropertyItem(PropertyItemBase propertyItem, object item) { if (propertyItem.Editor != null && ContainerHelperBase.GetIsGenerated(propertyItem.Editor)) { propertyItem.Editor = null; } base.ClearChildrenPropertyItem(propertyItem, item); }
private void RebuildEditor(PropertyItem propertyItem) { ObjectContainerHelperBase objectContainerHelperBase = propertyItem.ContainerHelper as ObjectContainerHelperBase; //Re-build the editor to update this propertyItem FrameworkElement editor = objectContainerHelperBase.GenerateChildrenEditorElement(propertyItem); if (editor != null) { // Tag the editor as generated to know if we should clear it. ContainerHelperBase.SetIsGenerated(editor, true); propertyItem.Editor = editor; } }
public override void PrepareChildrenPropertyItem(PropertyItemBase propertyItem, object item) { _isPreparingItemFlag = true; base.PrepareChildrenPropertyItem(propertyItem, item); if (propertyItem.Editor == null) { FrameworkElement editor = this.GenerateChildrenEditorElement(( PropertyItem )propertyItem); if (editor != null) { // Tag the editor as generated to know if we should clear it. ContainerHelperBase.SetIsGenerated(editor, true); propertyItem.Editor = editor; } } _isPreparingItemFlag = false; }
internal void RebuildEditor() { var objectContainerHelperBase = this.ContainerHelper as ObjectContainerHelperBase; //Re-build the editor to update this propertyItem var editor = objectContainerHelperBase.GenerateChildrenEditorElement(this); if (editor != null) { // Tag the editor as generated to know if we should clear it. ContainerHelperBase.SetIsGenerated(editor, true); this.Editor = editor; //Update Source of binding and Validation of PropertyItem to update var be = this.GetBindingExpression(PropertyItem.ValueProperty); if (be != null) { be.UpdateSource(); this.SetRedInvalidBorder(be); } } }
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 ); }