How to set Z-Index
for a drawing object when us开发者_如何学Pythoning DrawingContext.DrawXXX()
methods?
The object that was drawn last will have a higher Z index. You can't change index of an already drawn objects. The only way is to draw in another order.
If you are using WPF (as you placed that tag), you can use, for example, Canvas control. Then you just create shapes you need like
Polyline obj = new Polyline(); //...
// ... set properties of obj
and add them to Canvas UIElementCollection:
yourCanvasName.Children.Add(obj);
//or
yourCanvasName.Children.Insert(i, obj);
First items of that collection will have higher Z index. You will also get advantages in that way: no need to redraw on window changes, can anytime move objects and change order.
精彩评论