// <summary>
        // Basic ctor
        // </summary>
        // <param name="property">Property to display</param>
        // <param name="valueDialogTemplate">Template to use</param>
        public PropertyValueDialogControl(PropertyEntry property, DataTemplate valueDialogTemplate)
        {
            Fx.Assert(property != null, "property parameter is null");
            Fx.Assert(valueDialogTemplate != null, "valueDialogTemplate parameter is null");

            ModelPropertyEntry modelPropertyValue = property as ModelPropertyEntry;

            if (modelPropertyValue != null)
            {
                _rootTransaction = modelPropertyValue.FirstModelProperty.Value.BeginEdit();
            }

            InitializeComponent();

            // Make sure we use PI-specific resources within this control
            this.Resources.MergedDictionaries.Add(PropertyInspectorResources.GetResources());

            // Hook into an opening of nested dialogs.  PropertyInspector class takes care of this for us.
            // However, we are using Blend's collection editor which doesn't do the same thing, so
            // we need to reproduce that behavior manually.
            PropertyValueDialogHost.AttachOpenDialogHandlers(this);

            // Hook into the standard set of Commands
            _defaultCommandHandler = new PropertyValueEditorCommandHandler(this);


            _OKButton.Click                += new RoutedEventHandler(OnOkButtonClicked);
            _cancelButton.Click            += new RoutedEventHandler(OnCancelButtonClicked);
            _contentControl.Content         = property.PropertyValue;
            _contentControl.ContentTemplate = valueDialogTemplate;

            //Handle the commit and cancel keys within the property inspector, that is hosted in the collection editor
            ValueEditorUtils.SetHandlesCommitKeys(this, true);
        }
        // <summary>
        // Helper that attaches the OpenDialogWindow command to a handler within this host
        // class.  The handler will automatically open and populate the dialog window when
        // the OpenDialogWindow command is fired.
        // </summary>
        // <param name="dialogRoot">UIElement that should handle the OpenDialogWindow command</param>
        public static void AttachOpenDialogHandlers(UIElement dialogRoot)
        {
            Fx.Assert(dialogRoot != null, "dialogRoot parameter is null");

            PropertyValueDialogHost dialogHost = new PropertyValueDialogHost();
            dialogRoot.CommandBindings.Add(new CommandBinding(PropertyContainer.OpenDialogWindow, dialogHost.OnOpenDialogWindow, dialogHost.OnCanOpenDialogWindow));
        }
Esempio n. 3
0
        // <summary>
        // Helper that attaches the OpenDialogWindow command to a handler within this host
        // class.  The handler will automatically open and populate the dialog window when
        // the OpenDialogWindow command is fired.
        // </summary>
        // <param name="dialogRoot">UIElement that should handle the OpenDialogWindow command</param>
        public static void AttachOpenDialogHandlers(UIElement dialogRoot)
        {
            Fx.Assert(dialogRoot != null, "dialogRoot parameter is null");

            PropertyValueDialogHost dialogHost = new PropertyValueDialogHost();

            dialogRoot.CommandBindings.Add(new CommandBinding(PropertyContainer.OpenDialogWindow, dialogHost.OnOpenDialogWindow, dialogHost.OnCanOpenDialogWindow));
        }