共用方式為


IRegisterMetadata 介面

更新:2007 年 11 月

會指定要求在中繼資料存放區中加入更多屬性的類別。

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

語法

Public Interface IRegisterMetadata

Dim instance As IRegisterMetadata
public interface IRegisterMetadata
public interface class IRegisterMetadata
public interface IRegisterMetadata

備註

您可以實作 IRegisterMetadata 介面,以提供自訂屬性來定義 Windows Presentation Foundation (WPF) 控制項的設計階段行為和外觀。每個設計階段中繼資料組件 (Assembly) 都必須包含實作 IRegisterMetadata 的型別。

範例

在下列程式碼範例中,會說明如何實作 IRegisterMetadata 介面。Metadata 類別會將裝飾項提供者附加至控制項。如需詳細資訊,請參閱逐步解說:建立設計階段裝飾項

' 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());
    }
}

請參閱

參考

IRegisterMetadata 成員

Microsoft.Windows.Design.Metadata 命名空間

MetadataStore

其他資源

中繼資料存放區