Search code examples
c#buttontextwindows-phone-8.1messagedialog

How to change MessageDialog button text


I want to make specified message dialog in c# windows phone 8.1 but i don't know how to change the button text Please help me!

I used this code :

 MessageItem kiirat = DataHandler.DeserializeRespMessage(resp);
 MessageDialog msgbox = new MessageDialog(kiirat.Text.ToString());
 await msgbox.ShowAsync();

but the button text is close, how to change it a same one?


Solution

  • Try this...

      MessageDialog msgDialog = new MessageDialog("message here... ", "title here");
    
      //add ok button
      UICommand okBtn = new UICommand("OK");
      okBtn.Invoked = OkBtnClick;
      msgDialog.Commands.Add(okBtn);
    
      //add cancel button
      UICommand cancelBtn = new UICommand("Cancel");
      cancelBtn.Invoked = CancelBtnClick;
      msgDialog.Commands.Add(cancelBtn);
    
      //show message
      await msgDialog.ShowAsync();
    
    //code for cancel click
    private void CancelBtnClick(IUICommand command)
    {
    }
    
    //code for ok click
    private void OkBtnClick(IUICommand command)
    {
    }