0

I have a button that when you click it a popup is supposed to be displayed just showing a simple text message until the user clicks on the canvas. Do I have to do something like this in my button click method?:

    Window win2 = new Window();                   
    win2.Show();
    this.Close();

I just don't want to have another .xaml file for that window when all it's going to be doing is displaying a message for a short amount of time. Right now I'm using a Popup TextBlock but it's not quite what I want, since I can't make it movable.

pfinferno
  • 1,779
  • 3
  • 34
  • 62
  • 1
    Maybe you could provide more details about what exactly you want? What does your current solution look like, and what does your ideal solution look like? Can you draw us a picture? – Mike Strobel Nov 19 '14 at 19:48
  • 2
    Are You looking for MessageBox? : http://stackoverflow.com/questions/3830228/is-there-a-messagebox-equivalent-in-wpf – dzaba Nov 19 '14 at 19:51
  • Yes! That is what I was looking for. Wasn't sure if there was something like that or not. Thanks! – pfinferno Nov 19 '14 at 19:52

1 Answers1

0

WPF has a built in message box which you can use to display information then can easily be closed. This is used in many Windows applications as error popups.

MessageBoxResult result = MessageBox.Show("Text here ","Error", MessageBoxButton.OK, MessageBoxImage.Question);

Just place this inside your button click method and change the "Text Here" to whatever you want. https://msdn.microsoft.com/en-us/library/system.windows.messagebox(v=vs.110).aspx

Incisor
  • 328
  • 1
  • 16