MVVM Light Toolkit on Mono/MonoDroid? - mvvm

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).

Related

MVVM fresh vs MVVM light xamarin forms

I struggle to understand difference between mvvm fresh & mvvm light, Or I can say I am just jumping into it. So anybody just shed a light on it to be comfort to use it with xamarin.forms application.
I have used FreshMVVM in couple of mobile apps for both Small and Tablet devices. FreshMvvm is very light yet still gives you all the features you need and it is specifically designed to work on Xamarin Forms. It adds extra parts to existing Xamarin Forms capabilities like :
ViewModel Navigation
IOC
Automatic Wiring of ViewModels and Page events like (Appearing, Disappearing etc.)
It gives you the functionalities like Init and ReverseInit
It has built in Dialog service (alerts)
It supports Simple navigation, MasterDetail navigation and Tabbed Navigation
The Naming Conventions used are simple
It is very light and easy to implement
They have a very nice reference and detailed information in their project site.
https://github.com/rid00z/FreshMvvm
Update : What about MvvmLight?
All of these frameworks provides common features. Because the goal of all of them is same - providing cross platform tools that would support all of the above features I listed for FreshMvvm. The only differences however may be some of them might have some more features included and the way of implementing their Base Classes.
Recommendation for you : You should learn FreshMvvm (more light and easy to learn) and MvvmCross. These 2 are the current popular ones for Xamarin and Xamarin Forms platform.

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.

Communicating between MEF objects

I'm building a workbench/IDE style application which uses MEF to locate and load tools into the workbench at start up.
I'm using MVVM Light to build the workbench and the separate tools. I've got a point now where I want tools to be able to communicate which each other and the workbench.
I don't mean direct communication, more like "Hey I have some data here if anyone's interested" and interested tools can pick up the data.
This looks much like C# events and I know I can export an interface from my tool(s) which defines the event(s) but I'm also wondering about using the MVVM Light messenger to provide the communication.
I've seen on here that people are using the EventAggregator from Prism to do the same thing and as the messenger from MVVM Light is roughly analogous I figured I could use it.
I'm after advice really, has anyone used the messenger for MEF - MEF object and would you advocate it over plain old C# events.
What you are looking at here is the mediator pattern. You could use plain old C# events to do the same thing... but do to it right you would most likely end up implementing your own kind of pub/sub pattern. And if you are going to do that, why re-invent the wheel?
I like using prism's EventAggregator because it is part of the Prism framework injected with MEF. I use a lot of other things from Prism, so it's nice to get this for 'free'. It also promotes loose coupling with your components, and like all of the good mediator implementations it is implemented with the weak event pattern which prevents the memory issues you would need to avoid yourself when destroying objects that have subscribed to an event.
For what it's worth, I used to use MVVM Light, but I found Prism to be a more mature framework, with better documentation, examples and a larger user base to learn from. That's really just my opinion- I know loads of people who love MVVM Light. Play with them both and pick the one that makes you happy :)

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