views:

264

answers:

2

I have 2 UserControls: uc1 and uc2

On uc1.MouseOver, uc2 increases in size. On uc1.MouseLeave, uc2 returns to the original size.

On uc1.MouseLeftButtonUp, a popup is opened. However, when the popup is then closed, uc1.MouseLeave is not triggered, so uc2 doesn't return to it's original size.

A solution would be to have uc2 also subscribe to uc1.MouseLeftButtonUp, and execute the same code as on uc1.MouseLeave, but this is not a very elegant solution, as I have to repeat this for everything that subscribes to uc1.MouseLeave.

Is there a way to force the MouseLeave event programmatically?

+2  A: 

Consider making a method in your .cs file that your mouseleave (and mouseleftbuttonup) event calls.

xamlgeek
That's what I'm doing now (it's what I meant with the 'inelegant' solution)
eriksmith200
If you have a need for code that both responds to an event and to something else, it's not inelegant. It's refactoring.
Dave Swersky
A: 

Try this,

subscribe to the events on the MainPage.xaml.cs (even the popup close button click) and after each event ends you put this on the end of the event handling code:

e.Handled = true;

Gabriel Guimarães
the event args of the ChildWindow.Closed event doesn't have a Handled property
eriksmith200
aren't you closing the Popup by a click event ? it's the click even't that has this e.Handled property.
Gabriel Guimarães
I'm actually using a ChildWindow, sorry!
eriksmith200