다음을 통해 공유


UsesItemPolicyAttribute 클래스

업데이트: 2007년 11월

기능 공급자를 지정된 정책으로 제한합니다.

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

구문

<AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple := True)> _
Public NotInheritable Class UsesItemPolicyAttribute _
    Inherits RequirementAttribute

Dim instance As UsesItemPolicyAttribute
[AttributeUsageAttribute(AttributeTargets.Class, AllowMultiple = true)]
public sealed class UsesItemPolicyAttribute : RequirementAttribute
[AttributeUsageAttribute(AttributeTargets::Class, AllowMultiple = true)]
public ref class UsesItemPolicyAttribute sealed : public RequirementAttribute
public final class UsesItemPolicyAttribute extends RequirementAttribute

설명

모든 확장에서 정책을 지원하지는 않습니다.

예제

다음 코드 예제에서는 UsesItemPolicyAttribute를 사용하여 기능 공급자에 사용자 지정 서로게이트 정책을 연결하는 방법을 보여 줍니다. 전체 코드는 방법: 서로게이트 정책 만들기를 참조하십시오.

' The DockPanelAdornerProvider class implements an adorner
' that you can use to set the Margin property by using a 
' drag operation. The DockPanelPolicy class enables a 
' container policy for offering additional tasks and 
' adorners on the panel's children.
<UsesItemPolicy(GetType(DockPanelPolicy))>  _
Class DockPanelAdornerProvider
    Inherits AdornerProvider

    Public Sub New() 
        ' The adorner is a Rectangle element.
        Dim r As New Rectangle()
        r.Width = 23.0
        r.Height = 23.0
        r.Fill = AdornerColors.GlyphFillBrush

        ' Set the rectangle's placement in the adorner panel.
        Dim placement As New AdornerPlacementCollection()
        placement.PositionRelativeToAdornerWidth(-1, 0)
        placement.SizeRelativeToAdornerDesiredHeight(1.0, 0)
        placement.SizeRelativeToAdornerDesiredWidth(1.0, 0)
        placement.PositionRelativeToAdornerHeight(-1.0, 0)
        AdornerPanel.SetPlacements(r, placement)

        Dim p As New AdornerPanel()
        p.Children.Add(r)

        AdornerPanel.SetTask(r, New DockPanelMarginTask())

        Adorners.Add(p)
    End Sub
End Class
// The DockPanelAdornerProvider class implements an adorner
// that you can use to set the Margin property by using a 
// drag operation. The DockPanelPolicy class enables a 
// container policy for offering additional tasks and 
// adorners on the panel's children.
[UsesItemPolicy(typeof(DockPanelPolicy))]
class DockPanelAdornerProvider : AdornerProvider
{
    public DockPanelAdornerProvider() 
    {
        // The adorner is a Rectangle element.
        Rectangle r = new Rectangle();
        r.Width = 23.0;
        r.Height = 23.0;
        r.Fill = AdornerColors.GlyphFillBrush;

        // Set the rectangle's placement in the adorner panel.
        AdornerPlacementCollection placement = new AdornerPlacementCollection();
        placement.PositionRelativeToAdornerWidth(-1, 0);
        placement.SizeRelativeToAdornerDesiredHeight(1.0, 0);
        placement.SizeRelativeToAdornerDesiredWidth(1.0, 0);
        placement.PositionRelativeToAdornerHeight(-1.0, 0);
        AdornerPanel.SetPlacements(r, placement);

        AdornerPanel p = new AdornerPanel();
        p.Children.Add(r);

        AdornerPanel.SetTask(r, new DockPanelMarginTask());

        Adorners.Add(p);
    }
} 

상속 계층 구조

System.Object
  System.Attribute
    Microsoft.Windows.Design.RequirementAttribute
      Microsoft.Windows.Design.Policies.UsesItemPolicyAttribute

스레드로부터의 안전성

이 형식의 모든 공용 static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

참고 항목

참조

UsesItemPolicyAttribute 멤버

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

ItemPolicy

SelectionPolicy

FeatureProvider

FeatureConnectorAttribute

기타 리소스

기능 공급자 및 기능 커넥터

WPF Designer 확장성 이해