示例#1
0
        public TodoListPage()
        {
            Title = "You do";

            listView = new ListView();
            listView.ItemTemplate = new DataTemplate(typeof(ToDoItemCell));
            listView.ItemSelected += (sender, e) =>
            {
                var todoItem = (TodoItem)e.SelectedItem;
                var todoPage = new TodoItemPage();
                todoPage.BindingContext = todoItem;

                Navigation.PushAsync(todoPage);
            };

            var layout = new StackLayout();
            layout.Children.Add(listView);
            layout.VerticalOptions = LayoutOptions.FillAndExpand;
            Content = layout;

            ToolbarItem tbi = null;
            if (Device.OS == TargetPlatform.Android)
            {
                tbi = new ToolbarItem("+", "plus", () =>{
                    var todoItem = new TodoItem();
                    var todoPage = new TodoItemPage();
                    todoPage.BindingContext = todoItem;
                    Navigation.PushAsync(todoPage);
                },0,0);

            }

            ToolbarItems.Add(tbi);
        }
 public void SaveItem(TodoItem item)
 {
     if (item.ID != 0)
     {
         database.Update(item);
     }
     else
     {
         database.Insert(item);
     }
 }