adorner Z order

J

JFlorero

I asked this before in a different discussion group without luck. Perhaps
someone here can help me. What I need to do is change the Z order of all
adorners in a Canvas. What I have is many UserControls in a Canvas. Each has
an adorner. When I change the Z-order of the user control, it's adorner
remain in the original Z-order in relation to the other adorners. I cannot
find a way to change this. Does anybody know how to do this?
 
J

JFlorero

Thanks for the link. It looks like they don't use adorners to select and move
the shapes or perhaps they do it in a different way. I will study the code to
see what I am doing wrong.

Thanks again for your help.
 
L

Linda Liu[MSFT]

Hi JFlorero,

This is a quick note to let you know that I'm performing research on this
issue and will get back to you ASAP.

I appreciate your patience!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
L

Linda Liu[MSFT]

Hi JFlorero,

Thank you for your quick response!

After doing some research, I find a solution to your question.

As we all know, an adorner is contained in an adorner layer. The adorner
layer's location in the visual tree of an application is always determined
by an AdornerDecorator element. Window provides an AdornerDecorator by
default, which is part of the window¡¯s default template.

So by default, all adorners in a window are added to a same adorner layer
which is at the top of the Z order and this is why all adorners appear
above all nonadorner elements in the window.

To solve your problem, a solution is to provide your own adorner decorator.
To do this, place the target UIElement to be adorned inside an
AdornerDecorator. For example:

<Window ... >
<Canvas>
<AdornerDecorator Name="ad1" Canvas.Top = "10" Canvas.Left = "10" >
<TextBlock Name = "txt1" Width="20" Height="20" Text="Test1"
/>
</AdornerDecorator>
<AdornerDecorator Name="ad2" Canvas.Top = "15" Canvas.Left = "15">
<TextBlock Name ="txt2" Width="20" Height="20" Text="Test2"
/>
</AdornerDecorator>
</Canvas>
</Window>

If an adorner is applied to the targetElement, as before, WPF will now use
the AdornerDecorator supplied here, instead of the one that the Window
provided. When
asked for an adorner layer, WPF walks the tree starting from the adorned
element and uses the first adorner decorator it finds. It generates an
AdornerLayer as a child of the decorator in the visual tree. Thus in this
case, the adorner for the txt1 will be added to a different adorner layer
than that the adorner for the txt2 is added to.

When you'd like to change the Z order of the two TextBlock at run time, you
need to change the Z order of the two AdornerDecorator instead. For example:

Canvas.SetZIndex(this.ad1, 2);
Canvas.SetZIndex(this.ad2, 1);

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top