AdornerDecorator Class
Updated: September 2010
Provides an AdornerLayer for the child elements in the visual tree.
Assembly: PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
| Exception | Condition |
|---|---|
| ArgumentException | An attempt is made to add more than a single child to the AdornerDecorator. |
AdornerDecorator can contain only one child element. That element can contain multiple elements that can be adorned.
The AdornerDecorator specifies the position of the AdornerLayer in the visual tree. It is typically used in a ControlTemplate for a control that might host Adorner objects. For example, the ControlTemplate of a Window contains an AdornerDecorator so that the child elements of the window can be adorned. The GetAdornerLayer method returns Nothing if you pass in an element that does not have an AdornerDecorator as an ancestor in its visual tree.
For more information about adorners and visual trees, see Adorners Overview and Trees in WPF.
The following example creates a ControlTemplate for a Window. The example adds a ContentPresenter as the child element of an AdornerDecorator. The logical child elements of the window can be adorned because the AdornerDecorator is in their visual tree.
<Style x:Key="{x:Type Window}" TargetType="{x:Type Window}"> <Setter Property="SnapsToDevicePixels" Value="true"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Window}"> <Grid Background="{StaticResource WindowBackgroundBrush}"> <AdornerDecorator> <ContentPresenter/> </AdornerDecorator> <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Visibility="Collapsed" IsTabStop="false"/> </Grid> <ControlTemplate.Triggers> <Trigger Property="ResizeMode" Value="CanResizeWithGrip"> <Setter TargetName="WindowResizeGrip" Property="Visibility" Value="Visible"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style>
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.