Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placing an adorner on a datatemplate in XAML only?

Tags:

c#

wpf

I have the following DataTemplate :

<DataTemplate>

<Grid>
<1-- Content -->
</Grid>

</DataTempalte>

I want to place an adorner on top of the content of the Grid.

How can I do that?

The adorner I want to use is another Grid.

Can we do this in pure XAML only?

Thanks

like image 334
user1202434 Avatar asked May 05 '12 14:05

user1202434


1 Answers

I have made very good experience with the following code:

http://www.codeproject.com/Articles/54472/Defining-WPF-Adorners-in-XAML

After adding some classes to your code base you are able to define Adorners in Xaml like so:

<local:AdornedControl x:Name="adornedControl" HorizontalAlignment="Center" VerticalAlignment="Center"
    HorizontalAdornerPlacement="Outside" VerticalAdornerPlacement="Outside" IsAdornerVisible="True"
        IsMouseOverShowEnabled="False">
<local:AdornedControl.AdornerContent>
    <Canvas x:Name="adornerCanvas" HorizontalAlignment="Center" VerticalAlignment="Center">
        <Thumb Canvas.Top="-5" Canvas.Left="-5" />
        <Thumb Canvas.Bottom="-5" Canvas.Left="-5" />
        <Thumb Canvas.Top="-5" Canvas.Right="-5" />
        <Thumb Canvas.Bottom="-5" Canvas.Right="-5" />
    </Canvas>
</local:AdornedControl.AdornerContent>
like image 52
SvenG Avatar answered Oct 14 '22 09:10

SvenG