forum

Home / DeveloperSection / Forums / How can I hide the popup, when mouse click on anywhere outside using wpf?

How can I hide the popup, when mouse click on anywhere outside using wpf?

Anonymous User 11669 19-Aug-2013
Hi developers!

I got my UserControl that contain:

    Button

    Popup (contain Text block)

.XAML file 

<UserControl>

<button Name="btnShowPopup" Content="Button" Click=" btnShowPopup _Click"/>

<Popup Name="popup" StaysOpen="true">

<TextBlock Text="Popup"/>

</Popup>

</UserControl> 

Code Behide 

private void btnShowPopup _Click(object sender, System.Windows.RoutedEventArgs e)

{

   this.popup.IsOpen=!this.popup.IsOpen;

}

QUESTION: I want to hide the popup, when mouse click on anywhere outside the btnShowPopup button.

please help me. thank in advance!


wpf wpf 
Updated on 19-Aug-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By