AdornerPlacementCollection Class

Enables precise placement of adorners within an AdornerPanel.

Namespace:  Microsoft.Windows.Design.Interaction
Assembly:  Microsoft.Windows.Design.Interaction (in Microsoft.Windows.Design.Interaction.dll)

Syntax

'Declaration
Public Class AdornerPlacementCollection _
    Inherits ObservableCollection(Of IAdornerPlacement)
'Usage
Dim instance As AdornerPlacementCollection
public class AdornerPlacementCollection : ObservableCollection<IAdornerPlacement>
public ref class AdornerPlacementCollection : public ObservableCollection<IAdornerPlacement^>
public class AdornerPlacementCollection extends ObservableCollection<IAdornerPlacement>

Remarks

Use the AdornerPlacementCollection class to specify the location, size, and scaling properties of an AdornerPanel relative to the control it adorns.

Call the PositionRelativeToAdornerHeight and PositionRelativeToAdornerWidth methods to place the AdornerPanel relative to its adorner control's height and width.

Call the SizeRelativeToAdornerDesiredWidth and SizeRelativeToContentHeight methods to size the AdornerPanel relative to its adorner control's size.

Call the corresponding content-based methods to size and position the AdornerPanel relative to the adorned content.

Calls to the size and position methods are cumulative. The following code example shows two calls to the PositionRelativeToAdornerHeight method, which have the effect of placing the AdornerPanel above the adorned control with a y-axis offset equal to the height of the adorner plus five pixels.

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

Examples

The following code example shows how to use an AdornerPlacementCollection to specify the position of an adorner in an adorner panel. For more information, see Walkthrough: Creating a Design-time Adorner.

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);

Inheritance Hierarchy

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

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

AdornerPlacementCollection Members

Microsoft.Windows.Design.Interaction Namespace

AdornerPanel

PrimarySelectionAdornerProvider

Other Resources

Walkthrough: Creating a Design-time Adorner

Walkthrough: Implementing a Rail Inside a Control

Adorner Architecture