示例#1
0
        private static void ListModels(object param)
        {
            Menu menu = new Menu()
            {
                Title                = "List of all models",
                MenuItems            = new List <MenuItem>(),
                BuildMenuItemsAction = delegate(Menu m)
                {
                    m.MenuItems = new List <MenuItem>();
                    IEnumerable <ViewPerson> models = new ExampleController().List();
                    if (models.Count() > 0)
                    {
                        m.MenuItems.Add(new MenuItem()
                        {
                            Label = "Back"
                        });
                        foreach (ViewPerson viewPerson in new ExampleController().List())
                        {
                            string key = viewPerson.Id.ToString();
                            m.MenuItems.Add(new MenuItem()
                            {
                                Label           = viewPerson.Name + " (" + key.Substring(0, 5) + "..." + key.Substring(key.Length - 5) + ")",
                                TaskAction      = ShowModel,
                                ActionParameter = viewPerson.Id
                            });
                        }
                    }
                    else
                    {
                        m.MenuItems.Add(new MenuItem()
                        {
                            Label      = "No models.",
                            Selectable = false
                        });
                    }
                }
            };

            menu.Show();
        }