다음을 통해 공유


AttributeTableBuilder.AddCallback 메서드

지정된 형식의 메타데이터가 필요할 때 호출되는 콜백을 추가합니다.

네임스페이스:  Microsoft.Windows.Design.Metadata
어셈블리:  Microsoft.Windows.Design.Extensibility(Microsoft.Windows.Design.Extensibility.dll)

구문

‘선언
Public Sub AddCallback ( _
    type As Type, _
    callback As AttributeCallback _
)
public void AddCallback(
    Type type,
    AttributeCallback callback
)
public:
void AddCallback(
    Type^ type, 
    AttributeCallback^ callback
)
member AddCallback : 
        type:Type * 
        callback:AttributeCallback -> unit 
public function AddCallback(
    type : Type, 
    callback : AttributeCallback
)

매개 변수

  • type
    형식: System.Type
    메타데이터 특성을 추가할 형식입니다.

설명

Callback은 요청 시 특성 테이블에 메타데이터를 추가할 수 있으며, 이는 테이블을 만들 때 메타데이터를 추가하는 방법보다 효율적입니다.

대규모 특성 테이블을 만드는 경우 AttributeCallbackBuilder 클래스와 함께 AddCallback 메서드를 사용합니다.

예제

다음 코드 예제에서는 AddCallback 메서드와 AttributeTableBuilder 클래스를 사용하여 특성 테이블을 만들고 값을 채우는 방법을 보여 줍니다. 이 코드 예제는 AttributeCallbackBuilder 클래스에 대해 제공되는 보다 큰 예제의 일부입니다.

// Container for any general design-time metadata to initialize.
// Designers look for a type in the design-time assembly that 
// implements IProvideAttributeTable. If found, designers instantiate 
// this class and access its AttributeTable property automatically.
internal class Metadata : IProvideAttributeTable
{
    // Accessed by the designer to register any design-time metadata.
    public AttributeTable AttributeTable
    {
        get
        {
            AttributeTableBuilder builder = new AttributeTableBuilder();

            // Build the attribute table by using the AttributeCallbackBuilder 
            // class. The attribute table is not populated until the designer
            // needs it, which is more efficient for large attribute tables.
            builder.AddCallback(
                typeof(Button),
                delegate(AttributeCallbackBuilder callbackBuilder)
                {
                    callbackBuilder.AddCustomAttributes(
                        new DefaultPropertyAttribute("Content"));

                    // Apply the ReadOnlyAttribute to the Background property 
                    // of the Button class.
                    callbackBuilder.AddCustomAttributes(
                        "Background",
                        new ReadOnlyAttribute(true));
                });

            return builder.CreateTable();
        }
    }
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

AttributeTableBuilder 클래스

Microsoft.Windows.Design.Metadata 네임스페이스

AttributeTable

AttributeCallbackBuilder