Looking for a MVVM example - mvvm

Are there complete MVVM example solutions that don't use a 3rd party frameworks, Silverlight, or WPF?? Maybe something with WSF? -- thanks

If you want a "clean" example on MVVM (no framework attached), I suggest looking at https://github.com/brentedwards/Movies
This is a project by Brent Edwards wich is used on his presentation: WPF with MVVM from the trenches.
There is also a video in wich Brent gives some of the hightights of this presentation on DNR TV Episode 184: WPF with MVVM from the trenches with Brent Edwards
If you're looking a no-wpf and no-sl implmentation, you should be looking for the Presentation pattern from Martin Fowler wich is the generic definition of the pattern.

Related

Why MvvmLight Over Mvvm in Xamarin.Forms?

While creating app in Xamarin Forms using Mvvm and MvvmLight, couldn't find significant reason of using MvvmLight. As all the features are already being provided by the xamarin forms/.net.
So if someone could point out the significance of MvvmLight (maybe with an example)?
This is probably just what people are used to using with WPF. Instead of re-learning the terminology of Xamarin.Forms Mvvm they stick with Mvvmlight.
There are probably other reasons. Mvvmlight focus solely on Mvvm where as Xamarin.Forms resources are more spread out so may not adapt to design pattern changes as quickly as MvvmLight.
If I were choosing an Mvvm library to use I would choose MvvmLight for the reasons stated above
I have been using MVVM light for some time, the one thing I love is that You can make UI changes to datatemplates during design time.
I am still new to Xamarin MVVM, but from what I can tell you have no design time preview in the shared project(Xamarin Forms) yet.
So MVVM light may not give you such an advantage.
Questions to ask yourself is why you would need an MVVM library in the first place.

MVVM Light Toolkit on Mono/MonoDroid?

is there a possibility to run the Galasoft MVVM Light Toolkit on Mono/Monodroid?
MVVM Light Toolkit uses a number of interfaces in the WindowsBase.dll of .Net that might not be implemented by mono. As the result shows, it cannot be used especially because the RelayCommand depends on the CommandManager of WPF.
You can run MoMA to determine the potential issues.
Here is another stackoverflow question with an answer, which appears to be monocross (not MVVM though).

MVVM in Windows Phone 7

Any good sample WP7 application using MVVM model in the optimal way?
I'm creating my first WP7 app, and I'm using MVVM as far as I can tell, but I'm not sure I'm doing it the right way. I have one view model per page, instead of one main view model that branches to each page, I'm not sure which is the correct way to do, so I'm hoping there's a sample app out there that I can check out.
Thanks!
Edit: I'm also having another problem on saving the ViewModels in the application state, because I think they have to be serializable (haven't worked much into this), the thing is that when I start a task and come back to the app, the latter has already been deactivated by calling the former, so I have to serialize its state when deactivated and [re]serialize it when [re]activated. This is how I save the state when deactivated:
object[] viewModels = new object[3];
viewModels[0] = App.ViewModelPage1;
viewModels[1] = App.ViewModelPage2;
viewModels[2] = App.ViewModePage3;
PhoneApplicationService.Current.State.Add("LastState", viewModels);
Again, this is probably not efficient way to do it, so I'm hoping I can see a sample app that handles this well too.
Thanks!
Have you looked at using the MVVM Light toolkit?
Serialization best practices will vary based on the volume of data in the model, the number of models being used and whether it's necessary to always load all of the models.
You might want to check out Caliburn Micro. It is used to implement a number of user experience patterns but it supports WP7 and has sample code.
Here's some MVVM samples and guidance you can check out.
C#er : IMage: Model-View-ViewModel (MVVM) Explained
.NET by Example: Using MVVM Light to drive a Windows Phone 7 / Silverlight 4 map viewer
The simplest way to do design-time ViewModels with MVVM and Blend.
Also an overview here of MVVM frameworks you may find worth a look.
JAPF » Blog Archive » Discover and compare existing MVVM frameworks
Light weight seems to be good and MVVM Light is popular. Laurent demos MVVM in the Mix 10 video EX14 if you want to check that out too.
This months MSDN magazine has an article on creating a WP7 Sudoko app using MVVM.
http://msdn.microsoft.com/en-us/magazine/gg490347.aspx
HTH
Here is my article which describes the approach to build WP7 applications using advantages of separation of concerns:
a framework for building of WP7 application

Should I use ICommand or Expression.Interactions InvokeCommand for MVVM in Silverlight 4?

I'm about to embark on a new project in Silverlight 4, and definitely want to take advantage of the MVVM pattern, now I've finally grasped the basics.
For implementing commands in Silverlight 4 it seems there are rather a lot of options ranging from the new built-in Command/ICommand option on the Button, over the InvokeCommand defined in the Microsoft.Expressions.Interactivity namespace and on to the range of assisting MVVM frameworks (Prism, MVVMlight etc).
Does anyone here have gotcha's, experience and wisdom to share on this subject?
I would say a good place to start is use a toolkit. Some one else has then troubled over how to implement these things.
have a look here at the MVVM Light Toolkit

Design Patterns in PRISM

I'm in some sort of confusion: at one hand Microsoft architects and surrounding web community promote MVVM pattern for building WPF apps, but from the other hand in Prism patterns and practices they uses absolutely other design patterns - MVP, Presentation Model and Supervising Controller! And not a single example of use pure MVVM! They even say nothing about using MVVM in their PRISM documentation! So, what should one do in this situation? Is it possible to use MVVM pattern in PRISM applications with the same level of freedom as with patterns listed above? I mean would it be more complex or not because of (probably) kind a native architectural optimization for these patterns?
Absolutely. PRISM glues the parts of your composite application together, but those parts may use MVVM or whatever pattern you prefer (as can your Shell).
You can definitely use MVVM with Prism.
Blaine Wastell from the Patterns and Practices group has said that the next version of Prism (v4) will contain more help for the MVVM pattern. I've read somewhere else that this means better support for MVVM in Blend, and more MVVM in the documentation.
http://blogs.msdn.com/blaine/archive/2010/01/15/prism-4-0.aspx