2011-07-18 3 views
6

Windows Phone 7에서 확인 대화 상자를 만들려면 어떻게해야합니까? howto는 Windows phone 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 경고 대화] (의
관련 문제