Friday, May 2, 2014

Inbuild Confirmation dialogue in WPF C#

To Create above confirmation dialogue just follow the below method

You need to add 
    using MahApps.Metro.Controls;
    using MahApps.Metro.Controls.Dialogs;

then write the function as below

                 private async Task showConfirmation(string message)
        {
            MessageDialogResult result = await this.ShowMessageAsync(message, "", MessageDialogStyle.AffirmativeAndNegative);
            if (result == MessageDialogResult.Affirmative)
            {
               //Do For ok Button
            }
            else
             {
                //Do For cancel Button
              }
        }

        private async void removeGameButton_Click(object sender, RoutedEventArgs e)
        {
            await showConfirmation("Remove : " + GameName + "?");
        }

2 comments: