Próbuję pokazać standardowy MessageBox jako okno modalne w mojej aplikacji, ale kończy się jako niemodalny. W pierwszym wywołaniu w poniższym kodzie pokazuję standardowy MessageBox, który jest pokazany jako modalny, tak jak powinien. W drugim wywołaniu nie jest pokazywana jako modalna, nawet jeśli złapię główny program rozsyłający okna.Modal MessageBox w aplikacji WPF
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();
}
}
dlaczego nie używasz okna WPF do tworzenia niestandardowych wiadomości? –
Muszę przestudiować dokumentację nieco więcej, wiadomość informacyjna nie jest domyślnie modalna, należy ustawić właściciela – klashagelqvist