次の方法で共有


PropertyOrder クラス

カテゴリまたはサブプロパティの一覧でプロパティが表示される順序を設定するために使用します。

継承階層

System.Object
  Microsoft.Windows.Design.OrderToken
    Microsoft.Windows.Design.PropertyEditing.PropertyOrder

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

構文

'宣言
Public NotInheritable Class PropertyOrder _
    Inherits OrderToken
public sealed class PropertyOrder : OrderToken
public ref class PropertyOrder sealed : public OrderToken
[<Sealed>]
type PropertyOrder =  
    class
        inherit OrderToken
    end
public final class PropertyOrder extends OrderToken

PropertyOrder 型で公開されるメンバーは以下のとおりです。

プロパティ

  名前 説明
パブリック プロパティ静的メンバー Default システム定義の既定の順序位置を取得します。
パブリック プロパティ静的メンバー Early システム定義の、前の順序位置を取得します。
パブリック プロパティ静的メンバー Late システム定義の、後の順序位置を取得します。

このページのトップへ

メソッド

  名前 説明
パブリック メソッド CompareTo この順序トークンを指定された順序トークンと比較します。 (OrderToken から継承されます。)
パブリック メソッド静的メンバー CreateAfter 指定したトークンの後に追加される PropertyOrder オブジェクトを作成します。
パブリック メソッド静的メンバー CreateBefore 指定したトークンの前に追加される PropertyOrder オブジェクトを作成します。
パブリック メソッド Equals 指定した Object が、現在の Object と等しいかどうかを判断します。 (OrderToken から継承されます。)
プロテクト メソッド Finalize オブジェクトがガベージ コレクションにより収集される前に、そのオブジェクトがリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。)
パブリック メソッド GetHashCode 特定の型のハッシュ関数として機能します。 (OrderToken から継承されます。)
パブリック メソッド GetType 現在のインスタンスの Type を取得します。 (Object から継承されます。)
プロテクト メソッド MemberwiseClone 現在の Object の簡易コピーを作成します。 (Object から継承されます。)
プロテクト メソッド ResolveConflict 2 つの OrderToken オブジェクトが等価と判断されたときに、既定の CompareTo 実装によって呼び出されます。 (OrderToken から継承されます。)
パブリック メソッド ToString 現在のオブジェクトを表す文字列を返します。 (Object から継承されます。)

このページのトップへ

解説

PropertyOrder のプライベート インスタンスを作成して、プロパティ ウィンドウ内の特定のプロパティ セットをグループ化します。

PropertyOrder クラスはプロパティの順序を制御します。これには、ルート プロパティやサブプロパティも含まれます。 ルート プロパティは、カテゴリ、アルファベット、PropertyOrder の順で並べ替えられます。 サブプロパティは、PropertyOrder 順に並べ替えられ、次にアルファベット順に並べ替えられます。

注意

この動作は、GetProperties メソッドを使用してプロパティの順序を決定する Windows フォーム デザイナーとは異なります。 WPF デザイナー では、プロパティは PropertyOrder クラスを使用して並べ替えられます。

PropertyOrder クラスにより、標準の順序トークンが提供されます。 システム定義のこれらの順序トークンには、EarlyDefault、および Late の各プロパティがあります。 Early 順序トークンは、プロパティ ウィンドウの上の位置を示します。

特定のプロパティ順序がないプロパティには、Default 順序が指定されます。 このクラスから派生して独自のカスタム順序トークンを作成すると、プロパティの順序とグループ化を指定できます。

次のコード例では、PropertyOrder から派生して、

Width プロパティと Height プロパティで使用する LayoutSizePriority クラスです。 これは、Early 順の後に作成されます。 したがって、一覧内で Early プロパティより後に表示されます。 LayoutAlignmentPriority は HorizontalAlignment プロパティと VerticalAlignment プロパティで使用され、LayoutSizePriority の後に作成されます。

PropertyOrder インスタンスは、PropertyOrderAttribute を使用してプロパティにバインドされます。 CreateBefore メソッドおよび CreateAfter メソッドは、Width の後に HeightHorizontalAlignment の後に VerticalAlignment を位置付けます。

Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports Microsoft.Windows.Design.PropertyEditing
Imports Microsoft.Windows.Design.Metadata

Public Class PropertyOrderTokens
    Private Shared layoutSizePriorityValue As PropertyOrder
    Private Shared layoutAlignmentPriorityValue As PropertyOrder


    Public Shared ReadOnly Property LayoutSizePriority() As PropertyOrder
        Get
            If layoutSizePriorityValue Is Nothing Then
                LayoutSizePriority = PropertyOrder.CreateAfter(PropertyOrder.Early)
            End If

            Return layoutSizePriorityValue
        End Get
    End Property


    Public Shared ReadOnly Property LayoutAlignmentPriority() As PropertyOrder
        Get
            If layoutAlignmentPriorityValue Is Nothing Then
                layoutAlignmentPriorityValue = PropertyOrder.CreateAfter(PropertyOrderTokens.LayoutSizePriority)
            End If

            Return layoutAlignmentPriorityValue
        End Get
    End Property
End Class

' Container for any general design-time metadata to initialize.
' Designers look for a type in the design-time assembly that 
' implements IProvideAttributeTable. If found, designers instantiate
' this class and access its AttributeTable property automatically.
Friend Class Metadata
    Implements IProvideAttributeTable

    ' Accessed by the designer to register any design-time metadata.
    Public ReadOnly Property AttributeTable() As AttributeTable _
        Implements IProvideAttributeTable.AttributeTable
        Get
            Dim builder As New AttributeTableBuilder()

            builder.AddCustomAttributes( _
                GetType(Button), _
                "HeightProperty", _
                New PropertyOrderAttribute( _
                    PropertyOrder.CreateAfter( _
                        PropertyOrderTokens.LayoutSizePriority)))

            builder.AddCustomAttributes( _
                GetType(Button), _
                "Width", _
                New PropertyOrderAttribute( _
                    PropertyOrder.CreateBefore( _
                        PropertyOrderTokens.LayoutSizePriority)))

            builder.AddCustomAttributes( _
                GetType(Button), _
                "VerticalAlignment", _
                New PropertyOrderAttribute( _
                    PropertyOrder.CreateAfter( _
                        PropertyOrderTokens.LayoutAlignmentPriority)))

            builder.AddCustomAttributes( _
                GetType(Button), _
                "HorizontalAlignment", _
                New PropertyOrderAttribute( _
                    PropertyOrder.CreateBefore( _
                        PropertyOrderTokens.LayoutAlignmentPriority)))

            Return builder.CreateTable()
        End Get
    End Property
End Class
using System;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Windows.Design.PropertyEditing;
using Microsoft.Windows.Design.Metadata;

public static class PropertyOrderTokens
{
    private static PropertyOrder layoutSizePriority;
    private static PropertyOrder layoutAlignmentPriority;

    public static PropertyOrder LayoutSizePriority
    {
        get
        {
            if (layoutSizePriority == null)
            {
                layoutSizePriority = PropertyOrder.CreateAfter(
                    PropertyOrder.Early);
            }

            return layoutSizePriority;
        }
    }

    public static PropertyOrder LayoutAlignmentPriority
    {
        get
        {
            if (layoutAlignmentPriority == null)
            {
                layoutAlignmentPriority = PropertyOrder.CreateAfter(
                    PropertyOrderTokens.LayoutSizePriority);
            }

            return layoutAlignmentPriority;
        }
    }
}

// Container for any general design-time metadata to initialize.
// Designers look for a type in the design-time assembly that 
// implements IProvideAttributeTable. If found, designers instantiate 
// this class and access its AttributeTable property automatically.
internal class Metadata : IProvideAttributeTable
{
    // Accessed by the designer to register any design-time metadata.
    public AttributeTable AttributeTable
    {
        get
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            builder.AddCustomAttributes(
                typeof(Button),
                "Height",
                new PropertyOrderAttribute(
                    PropertyOrder.CreateAfter(
                    PropertyOrderTokens.LayoutSizePriority)));

            builder.AddCustomAttributes(
                typeof(Button),
                "Width",
                new PropertyOrderAttribute(
                    PropertyOrder.CreateBefore(
                    PropertyOrderTokens.LayoutSizePriority)));

            builder.AddCustomAttributes(
                typeof(Button),
                "VerticalAlignment",
                new PropertyOrderAttribute(
                    PropertyOrder.CreateAfter(
                    PropertyOrderTokens.LayoutAlignmentPriority)));

            builder.AddCustomAttributes(
                typeof(Button),
                "HorizontalAlignment",
                new PropertyOrderAttribute(
                    PropertyOrder.CreateBefore(
                    PropertyOrderTokens.LayoutAlignmentPriority)));

            return builder.CreateTable();
        }
    }
}

スレッド セーフ

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

参照

参照

Microsoft.Windows.Design.PropertyEditing 名前空間

その他の技術情報

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

WPF デザイナーの機能拡張