IRegisterMetadata.Register 方法
更新:2007 年 11 月
會將設計階段中繼資料附加至特定控制項型別。
命名空間: Microsoft.Windows.Design.Metadata
組件: Microsoft.Windows.Design (在 Microsoft.Windows.Design.dll 中)
語法
Sub Register
Dim instance As IRegisterMetadata
instance.Register()
void Register()
void Register()
function Register()
備註
Register 是在設計工具初始化期間呼叫。
實作 Register 方法的類別都應該使用 AddAttributeTable 方法,將中繼資料加入至存放區。
範例
在下列程式碼範例中,會說明如何實作 Register 方法。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());
}
}
使用權限
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.Windows.Design.Metadata 命名空間