2012-07-04 24 views
0

我需要在VisualTree中創建一個與Application.Current.RootVisual同級的彈出窗口。有沒有辦法做到這一點?如何從可視樹中獲取彈出窗口,如果彈出窗口位於WP7的RootVisual級別

目前我找不到此方法。

我試圖獲得RootVisual的父級,但它沒有這樣的。

  var frame = Application.Current.RootVisual as PhoneApplicationFrame; 
      FrameworkElement fi = (FrameworkElement)VisualTreeHelper.GetParent(frame); 

在此先感謝

回答

2

這是錯誤的做法。

這裏是正確的,它的作品像一個冠軍:

  System.Collections.Generic.IEnumerable<Popup> popups = VisualTreeHelper.GetOpenPopups(); 
      Popup popup = popups.ElementAt(0);