简体   繁体   English

如何在C#Metro应用程序的``消息对话框''中显示供用户输入的文本框

[英]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, 我想在“消息”对话框中显示一个文本框以接受用户输入,然后单击“确定”按钮以检索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. 可以使用InputBox代替使用MessageDialog。 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. 此myvalue字符串返回您在输入文本框值中输入的内容。

i hope this will help you. 我希望这能帮到您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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