Silverlight 3 MouseLeave Event Controlling PopUp

I want to use the PopUp control (System.Windows.Controls.Primitives.PopUp) to display a context menu. After the leaves, the mice should be automatically closed. But the event handler for MouseLeave never gets 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;
}

      

Hello

Anton Kalchik

+2


source to share


2 answers


What type of child controls are in the popup? In other cases with WPF / Silverlight, I have child controls that swallow messages that would be good for the parent.



As an experiment, what happens if you attach MouseLeave handlers for child controls?

+1


source


you need to bind the event in Popup.Child instead of the popup itself, it might be a Silverlight bug.



+1


source







All Articles