Prism / MVVM / WPF, a "Real world" example, where?

Topics: Prism v1, Prism v2 - Silverlight 2, Prism v2 - WPF 3.5
Jul 16, 2009 at 10:25 PM
Edited Jul 16, 2009 at 11:01 PM

Hi there,

Starting to understand at least the big picture of this framework and the patterns used as MVVM i still feel that i
miss "the second half" of a complete application, I can create views "statically" but what about when we are adding requirements a;

"responsive applications" (threading / long operations / asynch)
"Notify the user what the application are doing" (state / icons or progress bars / task dialogs).

Most of the tutorials and articles i find never reach this far, they handle often much more specific UI problems and again never reach this far down the pipe. 

Is it only me who are wondering about things like:

How do i open a new window from my Commmand / Viewmodel?
How would i do this window or dialog modal to the opening window (I dont have any ref to the view in the viewmodel, correct??)
What is the best mechanism to report progress from a operation in "the service layer", e.g. imagine an operation that:

1. Uploads a file via webdav a file to a server.
(I want to report back the upload progress to the user)

2. Writes some metadata about the the file to a database via a WCF service. 

In the short example above, would it be best to execute the two sub operations from an ICommand, or should the complete operation be "encapsulated" in
a method in the service layer?

Is it only me who cant access the apps database directly but instead need to access data via a web service layer / remote (which gives problems compared to direct db access (client / server))?
Again, most examples on the web i find just take for granted that everyone in the world have direct access to the database as far as i can see.

Perhaps the reference implemenation are showing solutions to problems above and i just can find it. If so please tell me!!!
UPDATE: I just found out that the ref app are having something called 
RegionPopupBehaviors which seems to be able to open a window. Fanatstic!!!! But....shouldnt the documentation be extended to include information about such a common need, how to open a window in Prism, or do i really need to surf the web for such a problem?

You could argument that my wonderings here are not WPF specific at all, and thats why it isnt dealt with to much. To me..... i stil think i can find arguments why
an article about:

WPF + MVVM + Open modal Windows +  ICommand + Threading + "Reporting progress state back to the end user" etc....

would be VALUABLE and of course .... WPF realated!

My worry is that a framework that is so nice as Prism want get get the audience / usage as it deserves, not all people are working in the R&D department and have
limited time to solve the problems (which frameworks should be the solution to). I dont understand when the people behind frameworks have spent so much time being creative and producing
great things, to then not put as much energy and effort to tell the people what you can do with it, to promote it 100%. That way I think are risking the overall success of the framework to a great extent.

So.... is it only me who's having hard time to find these "end to end" examples on the web or do they exists? Are there any WPF gurus like the "WPF Disciples" dealing with these issues?

Finally, i do understand if this thread can be interpreted as a bit negative to Prism and perhaps to the people behind it. But please, try to read between the lines and think of what im trying to write here.
Basicly im justin calling for an extension to articles and frameworks, to handle and show the real potential of a good framework / technology for less inteligent people as me, how about a Prism for dummies perhaps :-)

Take care!

Best Regards

Jul 17, 2009 at 6:13 PM

Hi Niclas,

First, thanks for your feedback about the guidance, both good and bad since it one of the biggest ways for p&p to improve it. If you believe this suggestion could be useful for the community, please feel free to add an item in the Issue Tracker so people can vote for it, and it might taken into account for future versions of the guidance.

Related to your “reported progress problem”, and this is with no real knowledge about your application, a possible approach could be creating a module that exclusively handles progress reporting and similar tasks, which can get updates from the service (or a service of your own that interacts with the WebService) when it begins/is/finishes performing tasks. This module can then show the progress reports through views in the way that is required (showing them in regions in a StatusBar, in a Popup through the RegionPopupBehavior or any other option). Of course this is all simply explained, but I hope the idea is understandable.

It has to be taken into account that Prism is not a framework but a library (and guidance). It has a much lighter weight and a lot of extensibility points depending on your specific needs (lots of interfaces). One great thing about this is that is does not chain you to a specific approach of doing things, such as handling Web Service operations. Of course, this does not mean that guidance about web service communication would not be good (it is a topic of interest), but that there is no “the proper way” to do it, but the one that feels best for your application.

I hope my answer has been useful for you. There is also a good post from John Pappa where he discusses some similar problems and he talks about a future presentation framework (he is developing) that might address them.

Damian Schenkelman