I need to bring to front a custom control in WPF.
pseudoCode
OnMouseDown()
{
if (this.parent != null)
this.parent.BringToFront(this);
}
<
I found better solution. Get it:
foreach (var item in Grid1.Children)
{
if ((item as UIElement).Uid == "StackPan1")
{
UIElement tmp = item as UIElement;
Grid1.Children.Remove(item as UIElement);
Grid1.Children.Add(tmp);
break;
}
}
It is just example, not universal method. But you can use it in apps with dynamic adding of controls. This code just adds an element which you want to put on a top to the and of the UIElementCollection. It works if all of your elements have the same ZIndex.