Message Popup in WPF

Step 1: Create an empty WPF using Visual Studio, enter the name for the application and click on OK



Step 2: Create a button using the following code or drag and drop a button from the ToolBox of Visual Studio 2013.



Code:

  1. <Button Content="Button" HorizontalAlignment="Left" Margin="133,120,0,0" VerticalAlignment="Top" Width="75"/>  
Step 3: Name the button content and double click on the button, you will be getting this window



Enter the following code to make you click event activated with message box:
  1. MessageBox.Show("hI How are you");  
So the entire code of MainWindow.xaml.cs should be as below:
  1. using System;  
  2. usingSystem.Collections.Generic;  
  3. usingSystem.Linq;  
  4. usingSystem.Text;  
  5. usingSystem.Threading.Tasks;  
  6. usingSystem.Windows;  
  7. usingSystem.Windows.Controls;  
  8. usingSystem.Windows.Data;  
  9. usingSystem.Windows.Documents;  
  10. usingSystem.Windows.Input;  
  11. usingSystem.Windows.Media;  
  12. usingSystem.Windows.Media.Imaging;  
  13. usingSystem.Windows.Navigation;  
  14. usingSystem.Windows.Shapes;  
  15. namespacemessageapp  
  16. {  
  17.     ///<summary>  
  18.     /// Interaction logic for MainWindow.xaml  
  19.     ///</summary>  
  20.     publicpartialclassMainWindow: Window  
  21.     {  
  22.         publicMainWindow()  
  23.         {  
  24.             InitializeComponent();  
  25.         }  
  26.         privatevoidButton_Click(object sender, RoutedEventArgs e)  
  27.         {  
  28.             MessageBox.Show("hI How are you");  
  29.         }  
  30.     }  
  31. }  
Now run the WPF application:

Next Recommended Reading WPF popup UserControl