Bring element forward (Z Index) in Silverlight/WPF

前端 未结 7 1621
有刺的猬
有刺的猬 2020-12-04 19:42

All the documentation and examples I\'m finding online for setting Z-Index to bring an element forward in Silverlight are using a Canvas element as a container.

My i

相关标签:
7条回答
  • 2020-12-04 20:21

    set zIndex of your element in this way

    var zIndex = 
        ((Panel) element.Parent)
        .Children.Cast<UIElement>()
        .Max(child => Canvas.GetZIndex(child))
        ;
    
    zIndex++;
    
    Canvas.SetZIndex(element, zIndex);
    
    • maybe you need to check if zIndex is equal to int.MaxValue then reset "ZIndex"s.
    • but this almost never happens
    0 讨论(0)
提交回复
热议问题