Nota:
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Actualización: noviembre 2007
Se utiliza para establecer el orden en que aparecen las propiedades en una categoría o en una lista de subpropiedades.
Espacio de nombres: Microsoft.Windows.Design.PropertyEditing
Ensamblado: Microsoft.Windows.Design (en Microsoft.Windows.Design.dll)
Sintaxis
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
Comentarios
Cree instancias privadas de PropertyOrder para agrupar un conjunto determinado de propiedades en la ventana Propiedades.
La clase PropertyOrder controla el orden en que aparecen las propiedades, incluidas las propiedades raíz y las subpropiedades. Las propiedades raíz se ordenan primero en categorías, después alfabéticamente y, finalmente, por PropertyOrder. Las subpropiedades se ordenan por PropertyOrder y después alfabéticamente.
Nota: |
|---|
Este comportamiento difiere del Diseñador de Windows Forms, que utiliza el método GetProperties para determinar el orden de las propiedades. En WPF Designer, las propiedades se ordenan mediante la clase PropertyOrder. |
La clase PropertyOrder proporciona los tokens de orden estándar. Estos tokens de orden definidos por el sistema incluyen las propiedades Early, Default y Late. El token de orden Early hace referencia a una posición superior en la ventana Propiedades.
A las propiedades que no tengan un orden concreto se les asigna el orden Default. Puede derivar de esta clase y crear tokens de orden personalizados que garanticen el orden y la agrupación de las propiedades.
Ejemplos
En el ejemplo de código siguiente se muestra cómo derivar de PropertyOrder para implementar
una clase LayoutSizePriority que se utiliza para las propiedades Width y Height. Se crea después del orden Early. Por consiguiente, aparece en la lista después de las propiedades Early. LayoutAlignmentPriority se utiliza para las propiedades HorizontalAlignment y VerticalAlignment y se crea después de LayoutSizePriority.
Las instancias de PropertyOrder se enlazan a las propiedades mediante el atributo PropertyOrderAttribute. Los métodos CreateBefore y CreateAfter colocan Width delante de Height y colocan HorizontalAlignment delante de 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());
}
}
Jerarquía de herencia
System.Object
Microsoft.Windows.Design.OrderToken
Microsoft.Windows.Design.PropertyEditing.PropertyOrder
Seguridad para subprocesos
Todos los miembros static (Shared en Visual Basic) públicos de este tipo son seguros para la ejecución de subprocesos. No se garantiza que los miembros de instancias sean seguros para la ejecución de subprocesos.
Vea también
Referencia
Microsoft.Windows.Design.PropertyEditing (Espacio de nombres)
Nota: