解决popup不随着window一起移动的问题

源自 :

http://stackoverflow.com/questions/1600218/how-to-move-a-wpf-popup

http://social.msdn.microsoft.com/Forums/zh-CN/wpfzhchs/thread/2616e607-3954-4bfd-ae29-e0d813263030

public MainWindow()
{ 
 LocationChanged += new EventHandler(MainWindow_LocationChanged);
 }

void MainWindow_LocationChanged(object sender, EventArgs e)
{
//此方法 太牛叉了!简直神来之笔,参考链接1
var mi = typeof(Popup).GetMethod("UpdatePosition", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
mi.Invoke(popBottom, null);

//此方法容易导致 闪烁
//popBottom.ClearValue(Popup.IsOpenProperty);
 //popBottom.IsOpen = true;
}

posted @ 2011-07-06 19:04  xiaokang088  阅读(4183)  评论(1编辑  收藏  举报