次の方法で共有


PropertyOrder クラス

更新 : 2007 年 11 月

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

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

構文

'宣言
Public NotInheritable Class PropertyOrder _
    Inherits OrderToken
'使用
Dim instance As PropertyOrder
public sealed class PropertyOrder : OrderToken
public ref class PropertyOrder sealed : public OrderToken
public final class PropertyOrder extends OrderToken

解説

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


Friend Class Metadata
    Implements IRegisterMetadata

    ' Called by the designer to register any design-time metadata.
    Public Sub Register() Implements IRegisterMetadata.Register
        Dim builder As New AttributeTableBuilder()

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

        builder.AddCustomAttributes( _
            GetType(Button), _
            FrameworkElement.WidthProperty, _
            New PropertyOrderAttribute( _
                PropertyOrder.CreateBefore( _
                    PropertyOrderTokens.LayoutSizePriority)))

        builder.AddCustomAttributes( _
            GetType(Button), _
            FrameworkElement.VerticalAlignmentProperty, _
            New PropertyOrderAttribute( _
                PropertyOrder.CreateAfter( _
                    PropertyOrderTokens.LayoutAlignmentPriority)))

        builder.AddCustomAttributes( _
            GetType(Button), _
            FrameworkElement.HorizontalAlignmentProperty, _
            New PropertyOrderAttribute( _
                PropertyOrder.CreateBefore( _
                    PropertyOrderTokens.LayoutAlignmentPriority)))

        MetadataStore.AddAttributeTable(builder.CreateTable())

    End Sub
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;
        }
    }
}

internal class Metadata : IRegisterMetadata
{
    // Called by the designer to register any design-time metadata.
    public void Register()
    {
        AttributeTableBuilder builder = new AttributeTableBuilder();

        builder.AddCustomAttributes(
            typeof( Button ),
            FrameworkElement.HeightProperty, 
            new PropertyOrderAttribute(
                PropertyOrder.CreateAfter(
                PropertyOrderTokens.LayoutSizePriority)));

        builder.AddCustomAttributes(
            typeof(Button),
            FrameworkElement.WidthProperty, 
            new PropertyOrderAttribute(
                PropertyOrder.CreateBefore(
                PropertyOrderTokens.LayoutSizePriority))); 

        builder.AddCustomAttributes(
            typeof(Button),
            FrameworkElement.VerticalAlignmentProperty, 
            new PropertyOrderAttribute(
                PropertyOrder.CreateAfter(
                PropertyOrderTokens.LayoutAlignmentPriority))); 

        builder.AddCustomAttributes(
            typeof(Button),
            FrameworkElement.HorizontalAlignmentProperty, 
            new PropertyOrderAttribute(
                PropertyOrder.CreateBefore(
                PropertyOrderTokens.LayoutAlignmentPriority)));

        MetadataStore.AddAttributeTable(builder.CreateTable());
    }
}

継承階層

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

スレッド セーフ

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

参照

参照

PropertyOrder メンバ

Microsoft.Windows.Design.PropertyEditing 名前空間

その他の技術情報

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

WPF デザイナの機能拡張