DialogPropertyValueEditor Class

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

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

Syntax

'Declaration
Public Class DialogPropertyValueEditor _
    Inherits PropertyValueEditor
'Usage
Dim instance As DialogPropertyValueEditor
public class DialogPropertyValueEditor : PropertyValueEditor
public ref class DialogPropertyValueEditor : public PropertyValueEditor
public class DialogPropertyValueEditor extends PropertyValueEditor

Remarks

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.

Examples

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"
    xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:PropertyEditing="clr-namespace:Microsoft.Windows.Design.PropertyEditing;assembly=Microsoft.Windows.Design"
                    xmlns:Local="clr-namespace:CustomControlLibrary.Design"
                    x:Class="CustomControlLibrary.Design.EditorResources">

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

</ResourceDictionary>

Inheritance Hierarchy

System.Object
  Microsoft.Windows.Design.PropertyEditing.PropertyValueEditor
    Microsoft.Windows.Design.PropertyEditing.DialogPropertyValueEditor

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

Reference

DialogPropertyValueEditor Members

Microsoft.Windows.Design.PropertyEditing Namespace

EditModeSwitchButton

PropertyEntry

PropertyValue

PropertyValueEditorCommands

IInputElement

Other Resources

Property Editing Architecture

WPF Designer Extensibility