As promised, I am posting the sample code I covered in the presentation for everyone to download and start playing with. If you have any questions or would like me to discuss a specific aspect in more detail just drop me a line.
Download the Presentation Source. This contains the all sample code that I discussed during the presentation.
Useful links:
- The Composite WPF and Silverlight (Prism) website is where you want to start.
- Elegant Code Cast of Prism v2 ? David Starr, Scott Nichols, and myself sat down with the Patterns and Practices team to discuss Prism.
- Channel9 has some good videos available to help you understand and get started using Prism.
- WPF Recipes in C# 2008: A Problem-Solution Approach ? This is not a Prism book but it is a great book for solving common problems in WPF.
Thanks for the talk example code. Another question for you: you showed off a listbox-like control you wrote, do you follow the MVVM pattern for controls like that as well, or is that just for more ‘region like’ things?
@Tony Rasa
It really depends on the control you are creating. Most of the time you will not implement a MV-(whatever) pattern for control development. WPF controls are mainly made up of Dependenct Properties, but if you have a complex control I don’t see why you couldn’t use a pattern.
Hi Can I have the link to the presentation please.
Thanks
@Syed
The sample code for the presentation can be downloaded from the link in the blog post. If you are refering to a powerpoint, this presentation does not have a powerpoint presentation.
@Brian Lagunas
Hi Thanks for your reply I am in debate to know why in this code we have interface defined dor views and Presenter Model what are the advantages we can do it with concrete class why is this necessary in this example and what are the advantages?
@Brian Lagunas
Hi Brian!
Ignore my previous question I re write it again.
In this source code I found the view and presenter model both have Interface defined I know this is benefinial if we working out in Tier programming but I couldn’t understand the advantages of using this approach in MVVM concept I also cheked some codes examples from codeplex even they don’t used it. It might be some understanding I am missing here that is why I am asking you this question what are the benefits we can get to use Interface with view and model or what will be harm if we don’t have interface here.
I hope this is better explained.
Thanks
@Syed
This presentation covered both PRISM and MVVM, so the code is showing the MVVM implementation using the PRISM framework. The reason interfaces were used in both the ViewModel and the View is because we are using an IOC container to resolve them. This is just one way to implement the MVVM pattern. Of course there are many other variations. You just have to pick the one that works best for your situation.
I am currently following your code example to make my Prism/MVVM app. Currently I have three different modules out of which one would show up on the “DisplayMainRegion” at any given time. All three modules are however loaded through the AddModule() command. Now there is a corresponding toolbar button for each Module. Upon clicking the toolbar button I activate the module and it shows up on the MainRegion.
My question is that should we use Composite commands to do such an operation, when we are switching between modules, or should we have another layer such as a ModuleManager that would activate views?
@Farhan Asad
I would recommend using the commanding. The module that registers for the command should be responsible for showing itself. Each module should be dumb to any other module and have no dependencies of other modules.