How to display textbox for user input inside Message Dialog in c# metro apps

3.1k views Asked by At

I want to display a textbox inside my Message dialog to take user inputs & click OK button to retrieve textbox value in my MainPage.cs,

  private async void join_btn_Click(object sender, RoutedEventArgs e)
    {
        var messageDialog = new MessageDialog(" Enter your secure code Here");
        messageDialog.Title = "Join session";
        messageDialog.Commands.Add(new UICommand(
            "OK",
            new UICommandInvokedHandler(this.CommandInvokedHandlerOKFunction)));

        messageDialog.DefaultCommandIndex = 0;
        messageDialog.CancelCommandIndex = 1;
        await messageDialog.ShowAsync();
    }

Any suggestion about how to do it??

1

There are 1 answers

0
Mohan Gopi On

Instead of using MessageDialog you can use InputBox. Here you can get the textbox value. try the below code,

                string message, title, defaultValue;
                string myValue;
                message = "Enter Message Here :";
                title = "Title Name";
                myValue = Interaction.InputBox(message, title, defaultValue, 450, 450);

this myvalue string is return what ever your entered in the input Textbox value.

i hope this will help you.