2011-07-18 12 views
6

मैं विंडोज फोन 7 में एक पुष्टिकरण संवाद कैसे बना सकता हूं?विंडोज फोन 7 में एक पुष्टिकरण संवाद कैसे बनाएं?

मैं जिसमें मैं आइटम हटा सकते हैं एक ऐप्लिकेशन है, लेकिन जब कोई हटाएँ क्लिक करता है, मैं उसे एक पुष्टि संवाद जहां वे क्लिक कर सकते हैं 'पुष्टि' या 'बीच में बंद करें'

कैसे मैं यह कर सकता है प्राप्त करना चाहते हैं?

+2

संभव डुप्लिकेट http://stackoverflow.com/questions/:

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

इस तरह एक संवाद कुछ शो 4475602/WP7-सूचना-संवाद) –

उत्तर

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

तो ठीक/रद्द करें आप के लिए काफी अच्छा है, तो आप

1

बल्कि उपयोगकर्ता पूछ हटाने की पुष्टि करने से नियमित MessageBox.Show से चिपक कर सकता है, तो आप उपयोगकर्ता क्षमता देने पर विचार किया है आइटम?

हालांकि यह थोड़ा और काम हो सकता है, जब यह ऐप के teh संदर्भ में समझ में आता है तो यह एक बेहतर उपयोगकर्ता अनुभव का कारण बन सकता है।

26

आप इस का उपयोग कर सकते हैं:

enter image description here

[WP7 सूचना संवाद] (की
संबंधित मुद्दे