DialogPropertyValueEditor Class

Container for all dialog box-editing logic for PropertyEntry objects.

Inheritance Hierarchy


Namespace:  Microsoft.Windows.Design.PropertyEditing
Assembly:  Microsoft.Windows.Design.Interaction (in Microsoft.Windows.Design.Interaction.dll)


Public Class DialogPropertyValueEditor _
    Inherits PropertyValueEditor
public class DialogPropertyValueEditor : PropertyValueEditor
public ref class DialogPropertyValueEditor : public PropertyValueEditor
type DialogPropertyValueEditor =  
        inherit PropertyValueEditor
public class DialogPropertyValueEditor extends PropertyValueEditor

The DialogPropertyValueEditor type exposes the following members.


  Name Description
Public method DialogPropertyValueEditor() Initializes a new instance of the DialogPropertyValueEditor class.
Public method DialogPropertyValueEditor(DataTemplate, DataTemplate) Initializes a new instance of the DialogPropertyValueEditor class.



  Name Description
Public property DialogEditorTemplate Gets or sets the DataTemplate that is hosted by a host-specific dialog box and has its DataContext set to a PropertyValue.
Public property InlineEditorTemplate Gets or sets the DataTemplate that is used for an inline editor. (Inherited from PropertyValueEditor.)



  Name Description
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ShowDialog Called when the DialogEditorTemplate is nulla null reference (Nothing in Visual Basic) and a dialog box has been invoked by the user.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)



Use the DialogPropertyValueEditor class to show an inline editor that can have an associated dialog box editor.

The DialogPropertyValueEditor class can hold either a DataTemplate for a dialog box editor or custom logic that is called when the dialog box is invoked.

Use the EditModeSwitchButton in your DataTemplate to invoke your custom DialogPropertyValueEditor class.

You can provide a DataTemplate which is shown in a host dialog box, or you can override the ShowDialog method, which enables the reuse of existing or system dialog boxes.

The following list shows the rules for determining whether the DataTemplate or ShowDialog method is used.

  • If the DialogEditorTemplate property is not nulla null reference (Nothing in Visual Basic), that DataTemplate is hosted in a host-specific dialog box, which provides host styling. The ShowDialog is not called.

  • If the DialogEditorTemplate property is nulla null reference (Nothing in Visual Basic), the virtual ShowDialog method is called and you can override this method to show any dialog box.


The following code example shows how to create a dialog property value editor that displays an open file dialog when a custom FileName property is clicked in the Properties window. For more information, see How to: Create a Dialog Box Property Value Editor.

using System;
using System.ComponentModel;
using System.Windows;
using Microsoft.Windows.Design.Metadata;
using Microsoft.Windows.Design.PropertyEditing;
using Microsoft.Win32;

namespace CustomControlLibrary.Design
    public class FileBrowserDialogPropertyValueEditor : DialogPropertyValueEditor
        private EditorResources res = new EditorResources();

        public FileBrowserDialogPropertyValueEditor()
            this.InlineEditorTemplate = res["FileBrowserInlineEditorTemplate"] as DataTemplate;

        public override void ShowDialog(
            PropertyValue propertyValue,
            IInputElement commandSource)
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Multiselect = false;

            if (ofd.ShowDialog() == true)
                propertyValue.StringValue = ofd.FileName;
<ResourceDictionary xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"

    <DataTemplate x:Key="FileBrowserInlineEditorTemplate">
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="Auto"/>
            <TextBox Grid.Column="0" Text="{Binding StringValue}"/>
            <PropertyEditing:EditModeSwitchButton Grid.Column="1"/>


Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also


Microsoft.Windows.Design.PropertyEditing Namespace






Other Resources

Property Editing Architecture

WPF Designer Extensibility