内容简介:http://stackoverflow.com/questions/5666754/bringtofront-in-wpf
我需要在WPF中引导一个自定义控件.
伪代码
OnMouseDown()
{
if (this.parent != null)
this.parent.BringToFront(this);
}
我知道,我知道有一个ZIndex,但仍然不明白如何将简单的WinForm BringToFront替换为parent.SetZIndex(这个,MaxZIndex(parent)?1)?
也许在WPF这样一个很酷的事情中有更好的方法吗?
这是一个扩展函数,它将方法BringToFront功能添加到面板中包含的所有FrameworkElements中.
public static class FrameworkElementExt
{
public static void BringToFront(this FrameworkElement element)
{
if (element == null) return;
Panel parent = element.Parent as Panel;
if (parent == null) return;
var maxZ = parent.Children.OfType<UIElement>()
.Where(x => x != element)
.Select(x => Panel.GetZIndex(x))
.Max();
Panel.SetZIndex(element, maxZ + 1);
}
}
http://stackoverflow.com/questions/5666754/bringtofront-in-wpf
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Deep Learning
Ian Goodfellow、Yoshua Bengio、Aaron Courville / The MIT Press / 2016-11-11 / USD 72.00
"Written by three experts in the field, Deep Learning is the only comprehensive book on the subject." -- Elon Musk, co-chair of OpenAI; co-founder and CEO of Tesla and SpaceX Deep learning is a for......一起来看看 《Deep Learning》 这本书的介绍吧!