次の方法で共有


DialogPropertyValueEditor クラス

更新 : 2007 年 11 月

PropertyEntry オブジェクトのすべてのダイアログ ボックス編集ロジックのコンテナです。

名前空間 :  Microsoft.Windows.Design.PropertyEditing
アセンブリ :  Microsoft.Windows.Design (Microsoft.Windows.Design.dll 内)

構文

'宣言
Public Class DialogPropertyValueEditor _
    Inherits PropertyValueEditor
'使用
Dim instance As DialogPropertyValueEditor
public class DialogPropertyValueEditor : PropertyValueEditor
public ref class DialogPropertyValueEditor : public PropertyValueEditor
public class DialogPropertyValueEditor extends PropertyValueEditor

解説

DialogPropertyValueEditor クラスを使用して、インライン エディタを表示します。これに 1 つのダイアログ ボックス エディタを関連付けることができます。

DialogPropertyValueEditor クラスは、ダイアログ ボックス エディタ用の DataTemplate、またはダイアログ ボックスが起動されたときに呼び出されるカスタム ロジックを保持できます。

カスタム DialogPropertyValueEditor クラスを呼び出すには、DataTemplate 内で EditModeSwitchButton を使用します。

ホスト ダイアログ ボックスに表示される DataTemplate を提供するか、または既存のダイアログ ボックスかシステム ダイアログ ボックスを再利用できるようにする ShowDialog メソッドをオーバーライドできます。

DataTemplateShowDialog メソッドのどちらが使用されているかを判断するための規則を次に示します。

  • DialogEditorTemplate プロパティが nullnull 参照 (Visual Basic では Nothing) ではない場合、その DataTemplate は、ホストのスタイルを提供するホスト固有のダイアログ ボックスでホストされています。ShowDialog は呼び出されません。

  • DialogEditorTemplate プロパティが nullnull 参照 (Visual Basic では Nothing) の場合、ShowDialog 仮想メソッドが呼び出され、このメソッドをオーバーライドして、任意のダイアログ ボックスを表示できます。

次のコード例は、[プロパティ] ウィンドウでカスタム FileName プロパティがクリックされたときに [ファイルを開く] ダイアログを表示する、ダイアログ プロパティ値エディタを作成する方法を示しています。詳細については、「方法 : ダイアログ ボックス プロパティ値エディタを作成する」を参照してください。

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>

継承階層

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

スレッド セーフ

この型のすべてのパブリック static (Visual Basic では Shared) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

参照

参照

DialogPropertyValueEditor メンバ

Microsoft.Windows.Design.PropertyEditing 名前空間

EditModeSwitchButton

PropertyEntry

PropertyValue

PropertyValueEditorCommands

IInputElement

その他の技術情報

プロパティ編集アーキテクチャ

WPF デザイナの機能拡張