예제 #1
0
        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);
        }
예제 #2
0
 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));
 }
예제 #3
0
        public override void ClearChildrenPropertyItem(PropertyItemBase propertyItem, object item)
        {
            if (propertyItem.Editor != null &&
                ContainerHelperBase.GetIsGenerated(propertyItem.Editor))
            {
                propertyItem.Editor = null;
            }

            base.ClearChildrenPropertyItem(propertyItem, item);
        }
예제 #4
0
        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;
        }