2012-05-15 16 views
6

मैं अपने आवेदन में एक मॉडल विंडो के रूप में एक मानक संदेशबॉक्स दिखाने की कोशिश कर रहा हूं, लेकिन यह गैर मोडल के रूप में समाप्त होता है। पहले कॉल में, नीचे दिए गए कोड में मैं एक मानक संदेश बॉक्स दिखा रहा हूं जो मॉडल दिखाया गया है, जैसा कि इसे करना चाहिए। दूसरी कॉल में, इसे मोडल के रूप में नहीं दिखाया जाता है, भले ही मैं मुख्य विंडो प्रेषक को पकड़ूं।डब्ल्यूपीएफ आवेदन में मॉडल संदेशबॉक्स

Dispatcher disp = Application.Current.MainWindow.Dispatcher; 
//First call, shown MODAL 
if (this.messageService.ShowYesNo("Do you want to update the Word document, this will regenerate inspectiondata for document", "") == MessageBoxResult.Yes) 
{ 
    using (new WaitCursor()) 
    { 
     _eventAggregator.GetEvent<ProgressBarRequestShow>().Publish(""); 
     worker = new BackgroundWorker(); 

     worker.DoWork += delegate(object s, DoWorkEventArgs args) 
     { 
      AITUpdateProgressDelegate update = new AITUpdateProgressDelegate(UpdateProgress); 
      this.docService.UpdateWorddocument(this.docService.GetCurrentDocumentFilePath, update); 
     }; 

     worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) 
     { 
      try 
      { 
       // Second call NOT MODAL 
       disp.Invoke((Action)delegate() 
       { 
        this.messageService.ShowInformation("Document generated, choose Open in Word in main toolbar to show document", ""); 
       }); 
       _eventAggregator.GetEvent<ProgressBarRequestHide>().Publish(""); 
      } 
      finally 
      { 
      } 
     }; 
     worker.RunWorkerAsync(); 
    } 
} 
+0

कस्टम संदेशबॉक्स बनाने के लिए आप WPF विंडो का उपयोग क्यों नहीं करते? –

+0

मुझे दस्तावेज़ों का थोड़ा और अध्ययन करने की आवश्यकता है, एक सूचना संदेशबॉक्स डिफ़ॉल्ट रूप से मोडल नहीं है, किसी को स्वामी को सेट करने की आवश्यकता है – klashagelqvist

उत्तर

2

This ऐसा लगता है कि आप क्या देख रहे हैं। संदेश बॉक्स के लिए कॉल में 'स्वामी' पैरामीटर शामिल है। मैंने कोड में एक समान अवधारणा का उपयोग किया है जिसे मैंने पहले किया है और विंडोज़ को मोडल के रूप में दिखाया है। लिंक से नमूना कोड भी डाउनलोड किया जा सकता है।

संबंधित मुद्दे