AdornerManager Class

DevZest WPF Docking

AdornerManager Class
Provides attached properties to get or set a UIElement or DataTemplate as the adorner of FrameworkElement.
Inheritance Hierarchy
SystemObject  DevZest.WindowsAdornerManager

Namespace: DevZest.Windows
Assembly: DevZest.WpfDocking (in DevZest.WpfDocking.dll) Version: 2.5.0.0 (2.5.5912.0)
Syntax
public static class AdornerManager
Public NotInheritable Class AdornerManager

The AdornerManager type exposes the following members.

Methods
  NameDescription
Public methodStatic memberGetAdorner
Gets the value of Adorner attached property from a given FrameworkElement.
Public methodStatic memberGetAdornerTemplate
Gets the value of AdornerTemplate attached property from a given FrameworkElement.
Public methodStatic memberSetAdorner
Sets the value of Adorner attached property to a given FrameworkElement.
Public methodStatic memberSetAdornerTemplate
Sets the value of AdornerTemplate attached property to a given FrameworkElement.
Top
Fields
  NameDescription
Public fieldStatic memberAdornerProperty
Identifies the Adorner attached property.
Public fieldStatic memberAdornerTemplateProperty
Identifies the AdornerTemplate attached property.
Top
Attached Properties
  NameDescription
Public attached propertyAdorner
Gets or sets the adorner UIElement.
Public attached propertyAdornerTemplate
Gets or sets the adorner DataTemplate.
Top
Remarks

AdornerManager provides two attached properties: Adorner to get or set UIElement as adorner of FrameworkElement; and AdornerTemplate to get or set DataTemplate as adorner of FrameworkElement. You can use these attached properties to declare adorner of FrameworkElement in XAML.

AdornerTemplate provides similar functionality as Adorner, however it can be used in style setters because direct UI child is not allowed. Both way the provided adorner inherits DataContext as adorned element.

Setting adorner for specified FrameworkElement will clear the adorner previously set, no matter using Adorner or AdornerTemplate attached properties.

Examples
The following example demostrates the usage of Adorner and AdornerTemplate attached property:
XAML
<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:dz="http://schemas.devzest.com/presentation">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Button Content="Button" Grid.Row="0">
            <dz:AdornerManager.AdornerTemplate>
                <DataTemplate>
                    <Grid Opacity="0.5">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />
                        </Grid.ColumnDefinitions>
                        <Rectangle Fill="Blue"/>
                        <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontStyle="Italic" Text="{Binding Content}" />
                    </Grid>
                </DataTemplate>
            </dz:AdornerManager.AdornerTemplate>
        </Button>
        <Button Content="Button" Grid.Row="1">
            <dz:AdornerManager.Adorner>
                <Grid Opacity="0.5">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Rectangle Fill="Blue"/>
                    <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" FontStyle="Italic" Text="{Binding Content}" />
                </Grid>
            </dz:AdornerManager.Adorner>
        </Button>
    </Grid>
</Window>
See Also