次の方法で共有


CategoryEditor クラス

更新 : 2007 年 11 月

カスタム カテゴリ エディタを作成するための抽象クラスです。

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

構文

'宣言
Public MustInherit Class CategoryEditor
'使用
Dim instance As CategoryEditor
public abstract class CategoryEditor
public ref class CategoryEditor abstract
public abstract class CategoryEditor

解説

このクラスから派生して、プロパティ ブラウザ ホストのプロパティ セットにカスタム CategoryEditor を提供します。このクラスは、テキスト カテゴリのプロパティなど、互いに関連する一連のプロパティを編集するためのカスタム ユーザー インターフェイスを表します。

TargetCategory プロパティは、このエディタの編集対象となる互いに関連するプロパティのカテゴリを示します。たとえば、[プロパティ] ウィンドウのテキスト カテゴリの下には、テキスト関連プロパティがいくつか表示されます。これらのプロパティを編集するよう設計されたエディタの場合、TargetCategory プロパティは "Text" を返します。

EditorTemplate プロパティは、このエディタのビジュアル インターフェイス用の XAML テンプレートを返します。これは、通常、プロジェクト内の別の場所にある ResourceDictionary で用意されます。

CategoryEditor をデザイナで使用するには、まずこれを登録する必要があることに注意してください。詳細については、「IRegisterMetadata」を参照してください。

CategoryEditor クラスを使用する方法を次のコード例に示します。詳細については、「チュートリアル : カテゴリ エディタの作成」を参照してください。

Public Class TextCategoryEditor
    Inherits CategoryEditor

    ' The EditorResources class in this example inherits ResourceDirectory and
    ' contains the template for the category editor. This would be defined in 
    ' an associated XAML file named EditorResources.xaml
    Private res As New EditorResources()
    Public Overrides Function ConsumesProperty(ByVal prop As PropertyEntry) As Boolean
        Return True
    End Function

    Public Overrides ReadOnly Property EditorTemplate() As System.Windows.DataTemplate
        Get
            Return CType(res("TextCategoryEditorTemplate"), DataTemplate)
        End Get
    End Property

    Public Overrides Function GetImage(ByVal desiredSize As System.Windows.Size) As Object
        Return Nothing
    End Function

    Public Overrides ReadOnly Property TargetCategory() As String
        Get
            Return "Text"
        End Get
    End Property
End Class
public class TextCategoryEditor : CategoryEditor
{

    // The EditorResources class in this example inherits ResourceDictionary 
    // and contains template for the category editor. This would be 
    // defined in an associated XAML file named EditorResources.xaml
    private EditorResources res = new EditorResources();
    public TextCategoryEditor()
    {
    }

    public override bool ConsumesProperty(PropertyEntry property)
    {
        return true;
    }

    public override DataTemplate EditorTemplate
    {
        get
        {
            return res["TextCategoryEditorTemplate"] as DataTemplate;
        }
    }

    public override object GetImage(Size desiredSize)
    {
        return null;
    }

    public override string TargetCategory
    {
        get { return "Text"; }
    }
}

継承階層

System.Object
  Microsoft.Windows.Design.PropertyEditing.CategoryEditor

スレッド セーフ

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

参照

参照

CategoryEditor メンバ

Microsoft.Windows.Design.PropertyEditing 名前空間

その他の技術情報

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

WPF デザイナの機能拡張