Messagebox like the IPleaseWaitService

Topics: Questions
Jul 3, 2012 at 9:50 AM

Hello. Is there a Messagebox, which works like the IPleaseWaitService in Catel.

So where the Controls are disabled and the user get a Messagebox to answer a question?

Coordinator
Jul 4, 2012 at 6:06 PM

No. However, there is an EffectsHelper which can help you accomplish the same idea. Internally, the PleaseWaitWindow also uses the EffectsHelper to dimm the main window. 

 

1) Override the right methods in the MessageService implementation by adding EffectsHelper.Dimm(main window), EffectsHelper.Undimm(main window) before and after the messagebox.show

2) Register your custom MessageService implementation in the service locator

 

Have fun!

Jul 5, 2012 at 10:00 AM
Edited Jul 5, 2012 at 10:01 AM

Ok thanks. How do I get the mainwindow?  ;-)

Coordinator
Jul 5, 2012 at 10:08 AM

Catel.Environment.MainWindow ;)

Jul 5, 2012 at 11:00 AM

Thanks :-)

Jul 5, 2012 at 11:12 AM

Annother question.

Is there a way not to show a window, but a overlay.

something that looks like that:

http://stackoverflow.com/questions/6351612/wpf-mvvm-modal-overlay-dialog-only-over-a-view-not-window

Jul 6, 2012 at 10:13 AM

What do you think about add ModalContentPresenter class to Catel. Something like that:

http://programmingwithpassion.wordpress.com/2012/07/01/displaying-modal-content-in-wpf/

Coordinator
Jul 6, 2012 at 10:30 AM

If you want a different way, you need to implement your own version of the MessageService, then you can do whatever you want with it.

Jul 6, 2012 at 11:05 AM

Yes, its ok. It was just an suggestion to extend catel with a usefull control.

Jul 26, 2012 at 8:03 AM

Maybe you can help me anyway. Wan't to have an overlay on my view. So created an Catel:UserControl for the overlay. How to show this overlay from viewmodel and dimm the mainwindow?

Jul 26, 2012 at 9:31 AM

Or is it better to take a Window instead of an usercontrol

Coordinator
Jul 26, 2012 at 9:45 AM

Doesn't matter. I prefer windows (because a UC is just a fallacy for developers that don't know how to handle windows in MVVM), but this is totally up to you.

You can use the EffectsHelper to dimm the main window from any window you prefer. If you want the main window dimmed when a window is shown as dialog, create your own window or derive from DataWindow and call EffectsHelper.Dimm(Catel.Environment.MainWindow) or something like that.

Jul 26, 2012 at 12:23 PM
Edited Jul 26, 2012 at 12:23 PM

Ok.

One more question. Have now a Service class which have an instance of the window. Register the service in the Serviclocator.

What is the DataContext of the Window. The service class or implement also an ViewModel?

Coordinator
Jul 26, 2012 at 3:07 PM

I don't understand your question.

Jul 27, 2012 at 6:02 AM

Ok. I don't if this is the right way.

I implement a   Service. This service have an instance of the window. No in my MainViewModel I get the service an call Show. My Window needs to show data. So it needs a Datacontext. Whats the correct Datacontext? A ViewModel?

Jul 27, 2012 at 6:22 AM

Hello again.

Maybe this quesytion is better to understand.  How to show modal dialogs or message boxes inside a View-Model? That is the question that I found in the catel documantation. But I found not realy an answer.

So whats the correct way to show a modal Dialog (with Datacontext)  inside a ViewModel?

Jul 27, 2012 at 6:39 AM

You can use the UIVisualizerService to show a modal Dialog from within a ViewModel.

http://catel.catenalogic.com/mvvm_services_uivisualizerservice.htm

 

Jul 27, 2012 at 7:43 AM

Oh. That sounds good. Thanks.

Jul 27, 2012 at 12:18 PM
GeertvanHorrik wrote:

Doesn't matter. I prefer windows (because a UC is just a fallacy for developers that don't know how to handle windows in MVVM), but this is totally up to you.

You can use the EffectsHelper to dimm the main window from any window you prefer. If you want the main window dimmed when a window is shown as dialog, create your own window or derive from DataWindow and call EffectsHelper.Dimm(Catel.Environment.MainWindow) or something like that.

And where have I to call EffectsHelper.Dimm. Override ShowDialog in Window is not possible. Do I have to implement my own IUIVisualizerService or is there a other possibility.

Coordinator
Jul 27, 2012 at 12:26 PM

You might want to take a look at the Visibility property and respond to changes of that.

Another option is Loaded and Unloaded.