As explained before, when you navigate to a ViewModel object, Zebble will try to locate a View definition that provides a template for your view model.
If it finds one, then the view object is instantiated and binded to the view model, before the navigation starts.
However, if you have not defined any view or template for a given page (view model) then Zebble will generate one for you automatically!
Let's say you have defined the following view model in your project, but have not defined a view for it yet.
{
public Bindable<DateTime> Date = new Bindable<DateTime>(LocalTime.Today);
public Bindable<string> Tomorrow => Date.Get(x => x.AddDays(1).ToString("dd MMM yyyy"));
public void SayHi()=> Dialog.Alert("Hi");
public readonly CollectionViewModel<Item> Items = new CollectionViewModel<Item>();
protected override void NavigationStarted()
{
var shoes = Enumerable.Range(1, 4).Select(v => new Domain.Shoe { Brand = "Shoe " + v }).ToArray();
Items.Add(shoes);
}
public class Item : ViewModel<Domain.Shoe>
{
public Bindable<string> Brand => Source.Get(x => x.Brand);
public Bindable<string> ImageUrl => Source.Get(x => x.ImageUrl);
public void Tap()
{
Forward<ShoePage>(x => x.Source(Source));
// Which is equivalent to:
// The<ShoePage>().Source.Set(Source);
// Forward<ShoePage>();
}
}
}
For the above view model, Zebble will automatically show the following UI. Please note that: