MouseLeave event in Silverlight 3 PopUp control

Posted by AKa on Stack Overflow See other posts from Stack Overflow or by AKa
Published on 2009-09-19T09:48:55Z Indexed on 2010/03/24 10:23 UTC
Read the original article Hit count: 446

I want use PopUp (System.Windows.Controls.Primitives.PopUp) control to show some context menu. After mouse leaves, should automatically close. But eventhandler for MouseLeave is never executed. Why?

SAMPLE:

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;
}

Regards

Anton Kalcik

© Stack Overflow or respective owner

Related posts about popup

Related posts about silverlight-3.0