共用方式為


AdornerPlacementCollection 類別

更新:2007 年 11 月

AdornerPanel 中啟用裝飾項的精確定位。

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

語法

Public Class AdornerPlacementCollection _
    Inherits ObservableCollection(Of IAdornerPlacement)

Dim instance As AdornerPlacementCollection
public class AdornerPlacementCollection : ObservableCollection<IAdornerPlacement>
public ref class AdornerPlacementCollection : public ObservableCollection<IAdornerPlacement^>
public class AdornerPlacementCollection extends ObservableCollection<IAdornerPlacement>

備註

您可以使用 AdornerPlacementCollection 類別,指定 AdornerPanel 相對於其所裝飾之控制項的位置、大小和縮放屬性。

您可以呼叫 PositionRelativeToAdornerHeightPositionRelativeToAdornerWidth 方法,相對於 AdornerPanel 之裝飾項控制項的高度和寬度來放置它。

您可以呼叫 SizeRelativeToAdornerDesiredWidthSizeRelativeToContentHeight 方法,調整 AdornerPanel 相對於其裝飾項控制項的大小。

您可以呼叫對應的內容架構方法,調整 AdornerPanel 相對於所裝飾之內容的大小和位置。

對大小和位置方法的呼叫屬於累加性。在下列程式碼範例中,會示範對 PositionRelativeToAdornerHeight 方法的兩個呼叫,這兩個呼叫都能將 AdornerPanel 置於所裝飾之控制項上方,Y 軸位移等於裝飾項高度加上五個像素的位置。

' Position the adorner above the control it adorns.
placement.PositionRelativeToAdornerHeight(-1.0, 0)

' Position the adorner up 5 pixels. This demonstrates 
' that these placement calls are additive. These two calls
' are equivalent to the following single call:
' PositionRelativeToAdornerHeight(-1.0, -5).
placement.PositionRelativeToAdornerHeight(0, -5)
// Position the adorner above the control it adorns.
placement.PositionRelativeToAdornerHeight(-1.0, 0);

// Position the adorner up 5 pixels. This demonstrates 
// that these placement calls are additive. These two calls
// are equivalent to the following single call:
// PositionRelativeToAdornerHeight(-1.0, -5).
placement.PositionRelativeToAdornerHeight(0, -5);

範例

在下列程式碼範例中,會說明如何使用 AdornerPlacementCollection,指定裝飾項在裝飾項面板中的位置。如需詳細資訊,請參閱逐步解說:建立設計階段裝飾項

Dim placement As New AdornerPlacementCollection()

' The adorner's width is relative to the content.
' The slider extends the full width of the control it adorns.
placement.SizeRelativeToContentWidth(1.0, 0)

' The adorner's height is the same as the slider's.
placement.SizeRelativeToAdornerDesiredHeight(1.0, 0)

' Position the adorner above the control it adorns.
placement.PositionRelativeToAdornerHeight(-1.0, 0)

' Position the adorner up 5 pixels. This demonstrates 
' that these placement calls are additive. These two calls
' are equivalent to the following single call:
' PositionRelativeToAdornerHeight(-1.0, -5).
placement.PositionRelativeToAdornerHeight(0, -5)

AdornerPanel.SetPlacements(opacitySlider, placement)
AdornerPlacementCollection placement = new AdornerPlacementCollection();

// The adorner's width is relative to the content.
// The slider extends the full width of the control it adorns.
placement.SizeRelativeToContentWidth(1.0, 0);

// The adorner's height is the same as the slider's.
placement.SizeRelativeToAdornerDesiredHeight(1.0, 0);

// Position the adorner above the control it adorns.
placement.PositionRelativeToAdornerHeight(-1.0, 0);

// Position the adorner up 5 pixels. This demonstrates 
// that these placement calls are additive. These two calls
// are equivalent to the following single call:
// PositionRelativeToAdornerHeight(-1.0, -5).
placement.PositionRelativeToAdornerHeight(0, -5);

AdornerPanel.SetPlacements(opacitySlider, placement);

繼承階層架構

System.Object
  System.Collections.ObjectModel.Collection<IAdornerPlacement>
    System.Collections.ObjectModel.ObservableCollection<IAdornerPlacement>
      Microsoft.Windows.Design.Interaction.AdornerPlacementCollection

執行緒安全

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

請參閱

參考

AdornerPlacementCollection 成員

Microsoft.Windows.Design.Interaction 命名空間

AdornerPanel

PrimarySelectionAdornerProvider

其他資源

逐步解說:建立設計階段裝飾項

逐步解說:在控制項中實作滑軌

裝飾項架構