private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (sender == btnOk)
                result = MessageBoxResult.OK;
            else if (sender == btnCancel)
                result = MessageBoxResult.Cancel;
            else
                result = MessageBoxResult.None;

            messageBox.Close();
            messageBox = null;
        }
 public static MessageBoxResult Show(string caption, string text, MessageBoxButton button, MessageBoxImage image)
 {
     messageBox = new MetroMessageBox();
     messageBox.textMessage.Text = text;
     messageBox.MessageTitle.Text = caption;
     setVisibilityOfButtons(button);
     setImageOfMessageBox(image);
     messageBox.ShowDialog();
     return result;
 }
 private static void setImageOfMessageBox(MessageBoxImage image)
 {
     MetroMessageBox metro = new MetroMessageBox();
     SolidColorBrush brush = new SolidColorBrush();
     switch (image)
     {
         case MessageBoxImage.Warning:
             {
                 messageBox.setImage("warning.png");
                 messageBox.mainGrid.Background = (LinearGradientBrush)metro.Resources["yellowBackground"];
             }
             break;
         case MessageBoxImage.Question:
             {
                 messageBox.setImage("question.png");
                 messageBox.mainGrid.Background = (LinearGradientBrush)metro.Resources["greenBackground"];
             }
             break;
         case MessageBoxImage.Information:
             {
                 messageBox.setImage("information.png");
                 messageBox.mainGrid.Background = (LinearGradientBrush)metro.Resources["blueBackground"];
             }
             break;
         case MessageBoxImage.Error:
             {
                 messageBox.setImage("error.png");
                 messageBox.mainGrid.Background = (LinearGradientBrush)metro.Resources["redBackground"];
             }
             break;
         default:
             messageBox.image.Visibility = Visibility.Collapsed;
             break;
     }
 }