我想使用PopUp(System.Windows.Controls.Primitives.PopUp)控件來顯示一些上下文菜單。鼠標離開後,應該自動關閉。但MouseLeave事件處理程序永遠不會執行。爲什麼?Silverlight 3中的MouseLeave事件PopUp控件
示例:
void DocumentLibrary_Loaded(object sender, RoutedEventArgs e)
{
DocumentLibraryDialog documentLibraryDialog = new DocumentLibraryDialog();
_popUpDocumentLibraryDialog = new Popup();
_popUpDocumentLibraryDialog.Width = 70;
_popUpDocumentLibraryDialog.Height = 20;
_popUpDocumentLibraryDialog.MouseLeave += new MouseEventHandler(_popUpDocumentLibraryDialog_MouseLeave);
_popUpDocumentLibraryDialog.Child = documentLibraryDialog;
}
void _popUpDocumentLibraryDialog_MouseLeave(object sender, MouseEventArgs e)
{
Popup currentPopUp = (Popup)sender;
if (currentPopUp.IsOpen)
(currentPopUp.IsOpen) = false;
}
問候
安東Kalcik
這是我的解決方案。我將MouseLeave處理程序連接到子容器。關於AKA – 2009-11-16 14:37:07