简体   繁体   中英

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

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??

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM