DialogPropertyValueEditor Class

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

Inheritance Hierarchy

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

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

Syntax

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

The DialogPropertyValueEditor type exposes the following members.

Constructors

  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.

Top

Properties

  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.)

Top

Methods

  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.)

Top

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.Interaction"
                    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>

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

Microsoft.Windows.Design.PropertyEditing Namespace

EditModeSwitchButton

PropertyEntry

PropertyValue

PropertyValueEditorCommands

IInputElement

Other Resources

Property Editing Architecture

WPF Designer Extensibility