Domanda

I have a custom UserControl designed to allow an individual to select a region of an image. I would like to have this control act as a decorator that can draw the region-select handles on top of a child image.

However, adding the image as a child of the UserControl in XAML renders the image on TOP of the handles, which are Ellipse objects in a Canvas inside my UserControl.

How can I force the content of a UserControl to render on top of its children?

È stato utile?

Soluzione

Sounds like you are trying to create an adorner. Have a look at the MSDN adorners overview

However you can always just set the Canvas.ZIndex attached property so that things move higher up the rendering order.

Altri suggerimenti

Easiest way is to use an Adorner. Very simple to do.

An Adorner is basically an extra ui layer over top of a UIElement.

A good analogy would be a coffee table or dining room table with a thick piece of glass on top.

If you don't draw on the glass, all you see is the table. Once you draw on the glass, it's shown over top of the table.

If you want to get rid of what you drew, you just remove the glass or clean it.

The glass I this case would be an Adorner.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top