This topic has not yet been rated - Rate this topic

DialogPropertyValueEditor Class

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

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)
public class DialogPropertyValueEditor : 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.
Top
  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
  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 null 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

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.

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="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://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>


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ