Friday, February 15, 2013

Recap on 'what are AutoViews?'

There are a couple of blog posts on AutoViews available - but not that much info.

To try to help, here's a practical guide to what works today... All of this is based on the sample in

To add AutoViews:

You can use ViewModels in Droid and Touch only, although we do have some work in WP slowly underway.

If you want to use AutoViews, you have to add some more assembly references and a little bit more setup code.

After that, you can then provide AutoView definitions by a few routes...

AutoViews from C# in your ViewModels:
In each ViewModel you can add the IMvxAutoListViewModel interface and can then declare whether each ViewModel is a List or a Dialog, and you can also declare a Menu

See two examples of this:

AutoViews from JSON in EmbeddedResource files

In the ViewModel project, you can include AutoView JSON files - in a location found by convention.

See two examples of this in -

AutoViews from JSON in Content/Assets in your UI
In you UI projects you can override the JSON files in the ViewModel projects.

For example, see

What MvvmCross does with AutoView definitions...
At runtime, when the framework navigates to a ViewModel, then the framework:

  • loads a normal View if one exists (a normal view always beats an AutoView)
  • loads a View-project based AutoView if one exists
  • then goes looking for an AutoView in the Core project - looking for either Json or for that IMvxAutoListViewModel inteface.
  • if it finds nothing, then the UI can also use Reflection to guess a Dialog to show... but this is normally really very basic - just shows UITextFields for string properties and UIButtons for ICommands


My first attempt at this code is mainly for rapid prototyping - for Sketchflow-level coding

But later on...  maybe apps can actually use this for some or all screens...

Next steps?

We will make Dialog's for WP and WinRT one day soon (one day...)

We also want to extend the AutoView idea to Tabbed/Pivot pages - and maybe to Dialog's too.

Beyond that.... who knows? :)

I don't get it - show me some sample code...

Sure - the working sample is in:

No comments:

Post a Comment