示例#1
0
        public TemplateListPage()
        {
            this.Title = "Workout Creator";
			_viewModel = new SimpleTemplate ();
			//Sync templates with the server
			Manager.Instance.WorkoutTemplate.LoadTemplates (App.WorkoutCreatorContext.StaffMember.GymID);

			var templatesTask = _viewModel.GetSimpleTemplateGroups (App.WorkoutCreatorContext.StaffMember.GymID);

			ListView listView = new ListView
			{
				ItemTemplate = new DataTemplate(typeof(CustomViewCellTwoTextTwoButton)),
				VerticalOptions = LayoutOptions.FillAndExpand,
				RowHeight = 110,
				HasUnevenRows = true
			};
					
			Action<Task> action = (actionResult) =>
				Device.BeginInvokeOnMainThread (() => {


					listView.ItemsSource = _viewModel.SimpleTemplateGroups;
			});

			templatesTask.ContinueWith (action);


           
			listView.ItemTemplate.SetBinding(CustomViewCellTwoTextTwoButton.SimpleTemplateProperty, ".");
			listView.IsGroupingEnabled = true;
			listView.GroupDisplayBinding = new Binding ("Key");
			listView.GroupShortNameBinding = new Binding("Key");
			listView.GroupHeaderTemplate = new DataTemplate(typeof(HeaderCell)); 



            listView.ItemSelected += (sender, args) =>
                {
                    if (args.SelectedItem != null)
                    {
                        listView.SelectedItem = null;

                        SimpleTemplate template = (SimpleTemplate)args.SelectedItem;
                        this.Navigation.PushModalAsync(new ModalAssignMemberWorkoutPage(template));
                    }
                };

           

            this.Content = listView;
        }