PleaseWaitService question

Apr 17, 2012 at 10:49 PM

Hi,

how feasible would it be to be able to call an IPleaseWaitService for an individual View (eg by passing a VM in the call)?

My apps allow the user to open multiple non modal Views & I would love to be able to use an IPleaseWaitService for just a single View when the View initiates a time comsuming process.  IE The app (other than the View which called the IPleaseWaitService) would remain responsive while the IPleaseWaitService was active.

This implies that an app may have several IPleaseWaitServices running simultaneously.

Apr 18, 2012 at 7:29 AM

This is pretty complex because the view model is not aware of the view. However, maybe we can fix this for 3.2.

Apr 18, 2012 at 8:45 AM

Is it not possible to pass the vm to the 'service locator' and have the locator find the View associated with the vm?

 

Btw, in the process of porting a reasonable size test app to ver 3 & have just hit the:

              There is no window registered as 'AppWpfLib.App.ViewModels.UserEditViewModel' error.

Guess I am going to have to read up a bit now...

 

 

Apr 18, 2012 at 8:54 AM

No, because there is no actual reference from view model to view, but we can create a manager for that in 3.2. I have created a work item for this, you can subscribe to it if you are interested.

Have you read this documentation on how to convert your apps to 3.0?

Apr 18, 2012 at 9:02 AM

thanks, I will read the conversion documentation tonight.

May 17, 2012 at 8:37 PM

We implemented a fix that the please wait window always will use the active window as parent window.

May 17, 2012 at 9:29 PM

Thanks for the update. Bit busy elsewhere atm, but I will look at it as soon as I have some time.

I have put together my own VisualizerService (overrides  UIVisualizerService) which holds weak references to open views in a dictionary. Currently uses ViewModel.Title as the key. This allows me to prevent the same viewmodel being opened in a new window if it is already open (eg hidden or minimised). It also allows user to register views as 'not managed'. It isn't commercial code atm, but so far, seems to work well in my test apps

This has also enboldened me enough to create my own please wait service (not as fancy as yours) which can be passed a viewmodel to locate the window to shade, or just uses the active window if no viewmodel supplied. It also accepts  'dowork' & 'workdone' delegates. Allows user to easilly kick work in background thread & be notified when work complete. Added some 'GetPleaseWaitService' helper methods to my viewmodel base (derived from catel.ViewModelBase) and calling the service becomes very easy.

I have also disconnected all 'sub' windows from the main application window (set win.owner to null). This was to prevent all application windows being brought to top when user clicked on a window. Not sure if this has any ramifications, but havent hit any yet.