Navigating between Views in WPF MVVM - wpf

I am new to WPF and MVVM and am working on an application which has a few views. Right now I have a View(HomePageView) shown in the shellView's context. Now using a button in the HomePageView I want to load another View in place of the currently shown HomePageView. After looking it up on google, I found something about Event Aggregators. I would request someone to explain the implementation or direct to a good sample application.

If your new to WPF MVVM I'd suggest first picking a decent helper tool
There are quite a few options. MVVM Light, Prism, MEF
I'd suggest MVVM light. Simple and easy to get up and running. Prism isnt solely a MVVM Helper but includes features to assist with MVVM. Not done much with MEF myself or things like Caliburn Micro.
As for a sample to explain how navigation between views work with MVVM Light try:
http://www.codeproject.com/Articles/323187/MVVMLight-Using-Two-Views
MVVM Light on CodePlex:
http://mvvmlight.codeplex.com/
^^ link has forwards to some video presentations totally worth watching
Another nice sample using MVVM Light:
http://apuntanotas.codeplex.com/
These should help you get started and you always got https://stackoverflow.com/questions/tagged/wpf for particular questions :)

Related

WPF Multiple Instances of Windows and MVVM

How do I use multiple windows in an WPF MVVM app?
I have a Main Window with a menu control that needs to open up new instances of the window each time the item it is selected. I need to be able to show windows next to each other, it is a requirement and not page or usercontrol navigation.
Does anyone have an example of doing this?
I've read it is not recommended UI design but it is the requirement I have to implement.
Actually I have this working by using the WindowManager from Caliburn.Micro which seems like an very excellent framework for this type of application. I did look into prism but it seems over complicated and Caliburn is very easy to understand which did meet the requirements. I looked into MVVM Light but the documentation is horrible and lacks examples and I don't have time to figure it out.

Need guidance on whether to use Telerik WPF controls or Caliburn Micro or both

Not sure if this an appropriate forum for this, but I need some guidance from those who are further down the road than I am with WPF.
I've used Telerik Winform controls for a years and have mixed feelings about them. They look good, but they are deeply nested, have a steep learning curve, and sometimes don't perform the best. For example, just working with a RadWindow in the WPF designer, it's slow compared with native wpf controls.
I like Caliburn.Micro MVVM framework and MahApps metro styles, but to keep the same look and feel for a ribbon bar I'd need to use another third party tool (like Fluent) or just use the Microsoft Ribbon View control and figure out how to use templates and styles myself (or find an existing metro template for it).
I tried to combine Telerik and Caliburn but had trouble getting them to work. There is a Caliburn Telerik library but its based on Caliburn Micro 1.5.2 and I'm trying to use Caliburn.Micro 2.0.2. Problem is I always get an aero-looking full window title bar and frame wrapped around the Telerik styled window.
I just don't know enough about conventions and such to make it all work together. And frankly, not sure it's worth the trouble. I'm looking for a more streamlined approach that lessens my dependence on pricy and heavy third party controls.
So, I'm looking for guidance on whether I should use straight Telerik, straight caliburn or go through the work of trying to get them to work together.
What I would prefer is to use Caliburn as the mvvm framework with a layer of styling, like what MahhAps provides. And for those controls that aren't styled, like the Ribbon Bar, to either use Microsoft's ribbon bar and find templates and styles that would work or maybe a 3rd party control like Fluent. But would I be getting in over my head in trying to learn templates and styles?
Sorry for the ramble, but I'm frustrated and need some help in working through this. Thanks.
I found a great resource that maybe others new to WPF and struggling with similar questions would benefit from: MarkPad, a Code52 project on CodePlex.
It's written in WPF using Caliburn Micro MVVM framework (although it's version 1.5.2 rather than the current 2.0) and MahApps metro styles with some "roll your own" windows. It's a great looking app with the kind of simple menuing system I was looking for AND an MDI implementation. It's also a good example on how to organize a somewhat complex WPF application, something I was also unsure about.
It answers the question: Do I need to use Telerik? The answer is a definite NO. It's a great learning tool for me and maybe will be useful to others.

MVVM-Light/WPF Navigation Application

As I write a WPF application with MVVM Light, I'm trying to determine the best way to allow for Navigation in the application. I've been reading about creating Services, Interfaces, and Helpers, but unfortunately my head still hasn't grasped the great advice being offered on SO. I got down a spiral of starting with a simple class and some code behind to use MEF and/or Unity to accomplish my task.
What do you find to be the simplest way to add basic Navigation of a frame to an MVVM Light application built on WPF?
The problem seems light, but it's hard. The solution must cover several aspects as navigating to an existing view, closing a view, injecting the viewmodel before navigating to the view, animated transitions, etc.
Please check out Magellan a WPF framework created by Paul Stovell that covers all this issues and more!
A simple navigation mvvm-light navigation demo.
https://bitbucket.org/dbeattie/navdemo/src

Silverlight and MV(VM) Pattern - No Code-Behind - Is this possible?

I am working on Silverlight 3.0 and currently using code-behind in my Views. I would like to implement the MV(VM) pattern into my project as the project is growing. I have seen some WPF projects where the code-behind has NO CODE except for the InitializeComponent method, which I believe is the right way to go and just looks clean. Is this possible in Silverlight 3.0, that is, no code-behind?
Can anyone point me to some good Silverlight (3.0) MV(VM) tutorials / articles?
Without using some additional framework, Silverlight 3 does not support what you saw in WPF. Specifically, full Commanding support. Silverlight 4 has included Commanding for Buttons, which is a start.
You can look into other frameworks that provides this feature set, like Prism. This will get you along the right path, but I'm sure there are other options.
You can follow the MVVM pattern for Silverlight 3 applications without using a framework. However, it is much easier to use one of the many MVVM frameworks out there. Here are a few good ones:
MVVM Light
MEF
Simple MVVM
I'd recommend not using Prism as it is more complicated than it needs to be.
Other options include things like MVVM Light, which is lighter weight alternative to Prism for things like handling events and commands, however Prism does have a lot of functionality (and the Prism 4 talk has that sounding like a good option when it gets released).
One good community site to check out is the Composite Development Patterns Community, which was newly started but has an excellent goal of collecting articles and other help for working with development patterns like MVVM.
Lastly, John Papa gives a great overview of MVVM, limited to links so head to Google and look up "John Papa MVVM". :)
One thing to consider though, resources for SL3 aren't going to be as valuable as those for SL4, which opens up additional options for framework based commanding (ICommand that greglev mentioned), although it isn't still the full command support from WPF.
Jesse Liberty has a good primer on MVVM also using Behaviors for wiring events.
Silverlight and MV(VM) Pattern - No Code-Behind - Is this possible?

What WPF frameworks should I use?

I'm a newbie to WPF and I'm developing a brand new windows desktop application and I would like your opinion on what WPF framework I should use. I know this question has been asked before, but the last question was asked at least several months ago. A lot has changed since then.
Right now, I'm using MVVM Light which is more of a library than an actual framework, as the name suggests. I’m looking for something more comprehensive. I prefer a framework that I can use on future WPF projects. Consequently, it should be general purpose and productive.
Any insights or suggestions?
If you are a newby I would suggest that you try to use PLAIN WPF first to get a feeling for it instead of right away extending WPF with other frameworks.
Your title is a bit confusing. WPF is just a graphics/UI layer. WVVM is a Model View ViewModel framework, for implementing a MVVM pattern using WPF ( or Silverlight ).
So, are you asking what design pattern you should use for your WPF application? ( As in MVC, MVVW, MVP, etc... ) Or are you asking which MVVM frameworks are compatible with WPF?
Ugh, acronym soup.
As to my answer, if you are new to WPF and want to learn WPF, I would start with no framework, you can always refactor later once you have a good solid grasp of the underlying technology.
It's definitely on the heavy weight end, and plenty of people will warn you about it, but you seem to be asking for CAG
http://compositewpf.codeplex.com/
It's a pattern that comes with a sample implementation that you can bend into your own. For example, it comes with Unity for IoC, but you should be able to put in another IoC container.
The download comes with a lot of samples for both Silverlight and WPF.
Caliburn (http://caliburn.codeplex.com/) handles a lot of shortcomings of the WPF inherent model (like writing a ton ot stupid routing code for events) and introduces MVVM ;) My bet ;)
You might have a look at the WPF Application Framework (WAF). The sample applications show:
View composition
UI Workflow (Wizards)
Command binding / Shortcut Keys
MVVM pattern, Unit Testing
Validation
Entity Framework
Open/Save FileDialog
Print Preview / Print Dialog
Localization

Resources