[英]How to check if user input is not a number and then display a message in C#?
[英]How to display textbox for user input inside Message Dialog in c# metro apps
我想在“消息”對話框中顯示一個文本框以接受用戶輸入,然后單擊“確定”按鈕以檢索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();
}
關於如何做的任何建議?
可以使用InputBox代替使用MessageDialog。 在這里您可以獲取文本框值。 試試下面的代碼,
string message, title, defaultValue;
string myValue;
message = "Enter Message Here :";
title = "Title Name";
myValue = Interaction.InputBox(message, title, defaultValue, 450, 450);
此myvalue字符串返回您在輸入文本框值中輸入的內容。
我希望這能幫到您。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.