Greg Mercer (1) [Avatar] Offline
#1
CountersView.cs
[ 922 bytes ]
I've really found the book very useful, and it comes at a perfect time for our project. So first off... thanks very much for a great book Jim!

I have been experimenting a bit with the Countr example... and at the moment I've only specifically made changes to the iOS portion.

I wanted to see what it would be like to add something that would show a detailed page when an item was selected. Now mind you I've really only got the show "CounterViewModel" working at the moment. And there are certainly some issues with what I got working so far but... I've uploaded the code up to this point just to share.

I haven't tried yet to understand how to get this working for Droid, but I think this might be a useful feature to add to Countr app example in the book.

Anywayz thanks again Jim.
Jim Bennett (38) [Avatar] Offline
#2
Hi Greg,

Thanks for your feedback, and I'm glad you are finding the book useful.

I agree that it would be a useful example to add, and was something I was thinking about adding but unfortunately there is only so much space in a book so I left it out. It's good feedback though - if others agree that it would be a useful example then I'll either add it to the book, or make it available as an appendix. The curse of books - making sure the content is useful to everyone without it being too big!

What you've done is correct - create the command and bind it so that all the logic is in the cross platform layers. The only change to make is in the service. The AddCounter method just takes a name and builds a counter from it, but you could always change it to always take a counter from the CounterViewmodel and save that. This would save a new counter as a new row or overwrite the existing one based off the auto incrementing ID without you having to make any other changes - the repository uses InsertOrReplaceAsync to update the SQLite database so handles both new counters and updates.

On Android it's easy to wire up the command - just add the item selected command to your recycler view binding in the AXML:

local:MvxBind="ItemsSource Counters; ItemClick ItemSelectedCommand"


Let me know how you go and if I can provide any more help.

Jim