Wednesday, November 14, 2012

Lists in MvvmCross AutoView - first code :)

I've just completed the first stab at a List AutoView :)

This code still needs a little tinkering with - it will change as we go across to the other platforms, but a basic first pass is in this Gist:

private KeyedDescription GetMenuAutoView()
{
var auto = new ParentMenuAuto()
{
new MenuAuto(caption: "New",
longCaption: "New Customer",
icon: "ic_menu_add",
command: () => AddCommand),
};
return auto.ToParentMenuDescription();
}
private KeyedDescription GetListAutoView()
{
var list = new ListAuto(key: "General",
itemsSource: () => Customers,
selectedCommand: () => CustomerSelectedCommand);
list.DefaultLayout = new ListLayoutAuto<Customer>(key: "General",
layoutName: "TitleAndSubTitle")
{
new BindingAuto<Customer>("Title", c => c.Name),
new BindingAuto<Customer>("SubTitle", c => c.Website)
};
return list.ToDescription();
}
public bool SupportsAutoView(string type)
{
switch (type)
{
case MvxAutoViewConstants.List:
return true;
case MvxAutoViewConstants.Menu:
return true;
default:
return false;
}
}
public KeyedDescription GetAutoView(string type)
{
switch (type)
{
case MvxAutoViewConstants.List:
return GetListAutoView();
case MvxAutoViewConstants.Menu:
return GetMenuAutoView();
default:
return null;
}
}
view raw gistfile1.txt hosted with ❤ by GitHub


Next up MonoTouch, and then WP and WinRT

Then back to Droid for Tab UIs too :)

No comments:

Post a Comment