I new to WPF C# and I’m looking for some direction. I have a text box that pops up on an error, I want the user to be able to click any where on the form to close this window. I’m not really sure of what search terms to use or where to start. Any help or smart ass comments like, “have you heard of google” are appreciated 🙂
like,
if mouse clicked
hide();
Thanks,
rd42
My final solution:
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Hide();
}
Here is an easy solution using a
Popupwindow.From your codebehind, just do this when it is time to display the popup.
Clicking anywhere outside of the Popup will produce the desired effect.
If you are using a traditional window, just subscribe to its
LostFocusorDeactivateevent and close it there (assuming that it is not shown as a dialog). Honestly though, the Popup is the easiest and best solution for cases like this.