2011-07-18 9 views
6

Windows Phone 7で確認ダイアログを作成するにはどうすればよいですか?howto Windowsの電話機7で確認ダイアログを作成しますか?

私はこれをどのように行うことができます

私はアイテムを削除することが可能なアプリを持っている、誰かが削除クリックしたとき、私は彼に、彼らは「確認」をクリックするか、「中止」することができます確認ダイアログを取得したい

+2

が重複する可能性http://stackoverflow.com/questions/:

if(MessageBox.Show("Are you sure?","Delete Item", MessageBoxButton.OKCancel) == MessageBoxResult.OK) { //Delete Sentences } 

は、このようなダイアログに何かを表示します4475602/wp7-alert-dialog) –

答えて

4

ここに私が使用する方法があります。ところで、より良いユーザーエクスペリエンスと一貫性のために、「確認」または「中止」ではなく、「削除」および「キャンセル」という言葉を使用することを検討してください。

public static MessagePromptResult Show(string messageBoxText, string caption, string button1, string button2) 
    { 
     int? returned = null; 
     using (var mre = new System.Threading.ManualResetEvent(false)) 
     { 
      string[] buttons; 
      if (button2 == null) 
       buttons = new string[] { button1 }; 
      else 
       buttons = new string[] { button1, button2 }; 

      Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox(
       caption, 
       messageBoxText, 
       buttons, 
       0, // can choose which button has the focus 
       Microsoft.Xna.Framework.GamerServices.MessageBoxIcon.None, // can play sounds 
       result => 
       { 
        returned = Microsoft.Xna.Framework.GamerServices.Guide.EndShowMessageBox(result); 
        mre.Set(); // could have done it all without blocking 
       }, null); 

      mre.WaitOne(); 
     } 

     if (!returned.HasValue) 
      return MessagePromptResult.None; 
     else if (returned == 0) 
      return MessagePromptResult.Button1; 
     else if (returned == 1) 
      return MessagePromptResult.Button2; 
     else 
      return MessagePromptResult.None; 
    } 

Microsoft.Xna.Framework.GamerServicesへの参照をプロジェクトに追加する必要があります。

0

キャンセル/ OKがあなたのために十分であるならば、あなたは

1

むしろ削除を確認するためにユーザに尋ねるよりも、通常のMessageBox.Showに固執する可能性は、あなたがユーザーに能力を与えると考えられているように、「非削除」アイテム?

これはもう少しうまくいくかもしれませんが、アプリのコンテキストで意味がある場合、ユーザーエクスペリエンスがはるかに向上します。

26

あなたはこれを使用することができます。

enter image description here

[WP7の警告]ダイアログ](の
関連する問題