views:

519

answers:

3

I am looking for a sample that demonstrates in the lightest way possible the following:

A Model that invokes a SOAP based web service; regularly polling to get the latest value (assume the SOAP service returns a boolean). The model should also support invoking a SOAP method that changes the boolean on the server.

A ViewModel that enables the underlying boolean to be bound to controls in the View (e.g. to a checkbox).

A View with the above checkbox control bound to the underlying boolean. Depending on the poll interval the checkbox will update as the server's state changes. If the checkbox is clicked the event will be dispatched to the model causing the server to be updated.

Optimally this sample will work on Windows Phone 7, but in a pinch I'd be happy with something that supported SL3 (no use of SL4 command routing allowed).

I am struggling with trying to understand how to make MVVM-Light work for me and I suspect that an expert could code a sample up like this very quickly... I also suspect this is a fairly common pattern for a lot of apps.

+2  A: 

Hi Cek,

Check this one out that was recently linked (by kP from memory?) over at wp7 forums.

http://dotnetbyexample.blogspot.com/2010/07/using-mvvm-light-to-drive-windows-phone.html

I doubt you'll find a "sample" that also happens to implement your "requirements", but at least with a sample that does what your question title describes you can learn and then apply your more detailed requirements to it.

Mick N
Joost's example was super helpful to me as well. It was not as simple as I had hoped for, but it did expose a couple of the key patterns. Thanks.
cek
yw :) /15char..
Mick N
+1  A: 
cek
As far as the Model question, in WP7 I use a model class for reading/writing to Transient memory and Isolated storage. ViewModels are for presenting data to be bound to by the Views/Pages. If you're using your Model like a view model, then maybe it should be a view model.
Matt Casto
I prefer calling DispatcherHelper.Initialize() in both App.xaml.cs' Appliance_Launching and Appliance_Activated methods.
Matt Casto
cek
+1  A: 

because otherwise it might not get re-initialised when the app returns from tombstoning

ant