Search code examples
windows-phonewindows-phone-8.1messagedialog

How to change the Button content as CamelCasing in Windows phone 8.1 Message dialog


How to change the Button content as CamelCasing in Windows phone 8.1 Message dialog?

    private async void Button_Click(object sender, RoutedEventArgs e)
    {
        MessageDialog msg = new MessageDialog("Do you want to continue?");
        msg.Commands.Add(new UICommand("Ok", (command) => { }));
        msg.Commands.Add(new UICommand("Cancel", (command) => { }));
        await msg.ShowAsync();           
    }

enter image description here

I want to change the ok as Ok and cancel as Cancel.


Solution

  • If you want a custom dialog you need to use a different control. The MessageDialog always lower cases the buttons to match the system style and is not generally customizable.

    If you use a ContentDialog you can customize it fairly extensively, and it doesn't try to fix the case of its buttons. You'll probably want to create your own ContentDialog class (there's a template under Add.New Item...) with your desired contents, but here's a quick content-free example:

    ContentDialog cd = new ContentDialog();
    cd.Title = "My Title";
    cd.PrimaryButtonText = "CoNtInUe";
    cd.SecondaryButtonText = "sToP";
    await cd.ShowAsync();
    

    Also note that the guidelines for message dialogs suggest using clear and specific verbs rather than generic OK/Cancel.