I am just getting started with Xamarin development (particularly Xamarin.Forms), and I love the MVVM pattern usage, as that's what I am used to with WPF development. I've been looking into the Xamarin Forms Labs and ACR Xamarin Forms projects for inspiration, and both focus heavily on MVVM, as they should. Now, here's my problem...
The majority of my app's views will be dynamically generated based on information from a database table. You can think of it as a wizard-based mobile application for filling out forms whose definitions (fields, number of "pages", etc.) are dynamically controlled by a series of database tables that define sections (wizard "pages" for each form, fields, and the data type for each field).
As you can see, with this approach, I don't know what the pages (views) will look like at design-time. All of the forms will by dynamically built at run-time! There are a couple of pages that are known ahead of time (main menu, welcome page (with dynamic list of available forms the user can fill out). Once a form is selected in the welcome page, each wizard page (section of the form with dynamic fields) are dynamically created and I don't know how many pages, etc. ahead of time. The forms themselves, along with their sections (wizard pages/steps), fields within each section (along with the appropriate data type), and hierarchy are all defined within a database hosted in the cloud and synchronized to the local client.
I suppose that if I want to go with an MVVM approach for these dynamic form pages (I think using XAML for these pages is out, unfortunately), then I can treat the form fields as records within a repeating list. Then I would have custom renderers for each field, perhaps? Remember, the field types are also dynamic, as defined in the database. For instance, a wizard page for a form (form section) could be defined as such:
1. Description: Have you checked the labels on the water heater?
Type: Yes/No (this would be displayed in a radio control)
2. Description: How many water heaters are there?
Type: Numeric (maybe displayed as a slider control)
3. Description: Take a picture of each water heater
Type: Image (need to use the phone's camera to take a variable number of pictures, based on the previous question)
As you can see, this is not a trivial problem! I would love to use the MVVM pattern throughout my application, but with the dynamic forms as outlined above, I just don't see how it's possible. I would also love to do it all in XAML, but also don't think that's possible with the dynamically defined forms.
Any suggestions??