コード例 #1
0
        private void InitializeToolBars()
        {
            string addIcon = null;
            string refreshIcon = null;

            if (Device.OS == TargetPlatform.WinPhone)
            {
                addIcon = "Toolkit.Content/ApplicationBar.Add.png";
                refreshIcon = "Toolkit.Content/ApplicationBar.Refresh.png";
            }
            var addToolButton = new ToolbarItem("Add", addIcon, () =>
            {
                var todoItem = new ToDoItem();
                var todoPage = new ToDoItemXaml();
                todoPage.BindingContext = todoItem;
                Navigation.PushAsync(todoPage);
            }, 0, 0);

            var refreshToolButton = new ToolbarItem("Refresh", refreshIcon, () =>
            {
                OnAppearing();

            }, 0, 0);

            ToolbarItems.Add(addToolButton);
            ToolbarItems.Add(refreshToolButton);
        }
コード例 #2
0
 public async Task SaveTaskAsync(ToDoItem item)
 {
     if (item.ID == null)
     {
         await _todoTable.InsertAsync(item);
         TodoViewModel.TodoItems.Add(item);
     }
     else
         await _todoTable.UpdateAsync(item);
 }
コード例 #3
0
 public async Task DeleteTaskAsync(ToDoItem item)
 {
     try
     {
         TodoViewModel.TodoItems.Remove(item);
         await _todoTable.DeleteAsync(item);
     }
     catch (MobileServiceInvalidOperationException msioe)
     {
         Debug.WriteLine(@"INVALID {0}", msioe.Message);
     }
     catch (Exception e)
     {
         Debug.WriteLine(@"ERROR {0}", e.Message);
     }
 }