Users Pricing

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 12219 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!


I am a content writter !


1 Answers