共用方式為


MetadataStore 類別

更新:2007 年 11 月

自訂設計階段屬性的容器。

命名空間:  Microsoft.Windows.Design.Metadata
組件:  Microsoft.Windows.Design (在 Microsoft.Windows.Design.dll 中)

語法

Public NotInheritable Class MetadataStore

您不需宣告靜態類別的執行個體,就能存取其成員。
public static class MetadataStore
public ref class MetadataStore abstract sealed
public final class MetadataStore

備註

您可以使用 MetadataStore 類別,將自訂設計階段屬性附加至型別。會指定 AttributeTable (使用 AttributeTableBuilder 所建立) 中的自訂屬性。

您可以使用 AddAttributeTable 方法,將屬性表格加入至中繼資料存放區。一旦加入之後,當您呼叫 TypeDescriptor 方法時,便會顯示這些屬性。

範例

在下列程式碼範例中,會說明如何建立 AttributeTable,以便讓裝飾項提供者與控制項類別產生關聯。如需詳細資訊,請參閱逐步解說:建立設計階段裝飾項

' Container for any general design-time metadata to initialize.
' Designers look for a type in the design-time assembly that 
' implements IRegisterMetadata. If found, designers instantiate 
' this class and call its Register() method automatically.
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()

        ' Add the adorner provider to the design-time metadata.
        builder.AddCustomAttributes(GetType(ButtonWithDesignTime), _
                                    New FeatureAttribute(GetType(OpacitySliderAdornerProvider)))

        MetadataStore.AddAttributeTable(builder.CreateTable())
    End Sub

End Class
// Container for any general design-time metadata to initialize.
// Designers look for a type in the design-time assembly that 
// implements IRegisterMetadata. If found, designers instantiate 
// this class and call its Register() method automatically.
internal class Metadata : IRegisterMetadata
{
    // Called by the designer to register any design-time metadata.
    public void Register()
    {
        AttributeTableBuilder builder = new AttributeTableBuilder();

        // Add the adorner provider to the design-time metadata.
        builder.AddCustomAttributes(
            typeof(ButtonWithDesignTime), 
            new FeatureAttribute(typeof(OpacitySliderAdornerProvider)));

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

繼承階層架構

System.Object
  Microsoft.Windows.Design.Metadata.MetadataStore

執行緒安全

這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。

請參閱

參考

MetadataStore 成員

Microsoft.Windows.Design.Metadata 命名空間

AttributeTable

AttributeTableBuilder

其他資源

中繼資料存放區