/// <summary> /// Causes the current window to be re-z-indexed to the top most window. /// </summary> public void BringToFront() { Canvas.SetZIndex(this, FloatableWindow.GetNextZ()); //// Search the top most "Window" and swap z-indexes. //Panel parent = this.Parent as Panel; // Panel is the base for Canvas, Grid and StackPanel. //if (parent != null) //{ // int currentZIndex = (int)this.GetValue(Canvas.ZIndexProperty); // var child = (from c in parent.Children where c is Window select c as Window).OrderByDescending(c => (int)c.GetValue(Canvas.ZIndexProperty)).FirstOrDefault(); // if (child != null) // { // int topZIndex = (int)child.GetValue(Canvas.ZIndexProperty); // if (topZIndex == 0) topZIndex = 1; // If the value has not been set then just default it to 1. // if (topZIndex > currentZIndex) // { // this.SetValue(Canvas.ZIndexProperty, topZIndex); // child.SetValue(Canvas.ZIndexProperty, currentZIndex); // } // } //} }
private void BringToFront() { var z = FloatableWindow.GetNextZ(); this.SetValue(Canvas.ZIndexProperty, z); }