public TodoListViewModel()
        {
            TodoItemViewModel = new TodoItemViewModel();

            AddCommand      = new RelayCommand(Add, CanAdd);
            CompleteCommand = new RelayCommand <TodoItemViewModel>(Complete, CanComplete);
            SyncCommand     = new RelayCommand(Sync, CanSync);
        }
        async void Complete(TodoItemViewModel todoItemViewModel)
        {
            try
            {
                Locator.Instance.IsBusy = true;

                // Mark todo item as done which raises INPC event so UI can react appropriately
                todoItemViewModel.Done = true;

                // Update the database to reflect the completed state
                await Locator.Instance.TodoItemTable.UpdateAsync(todoItemViewModel.TodoItem);

                // If connected then push changes to server but it won't pull any server updates
                if (Locator.Instance.IsSyncEnabled && await Locator.Instance.IsConnected())
                {
                    await Locator.Instance.PushChanges();
                }

                // Pause so UI can briefly show the checkmark
                await Task.Delay(250);

                // Delete item from the bound ViewModel to keep it in sync and so ObservableCollection
                // raises INPC which updates ListView to reflect deleted item
                Locator.Instance.TodoItems.Remove(todoItemViewModel);

                // If we don't pause here the ResetUI will effectively be ignored because it runs
                // asychonously with the previous ListView.Remove() and will complete before it
                await Task.Delay(225);

                // Reset UI in preparation for subsequent entries
                Messenger.Default.Send <ResetUI>(new ResetUI());
            }
            catch (Exception e)
            {
                // Something went wrong so rollback changes to ViewModel
                todoItemViewModel.Done = false;

                Messenger.Default.Send <PersistanceException>(new PersistanceException {
                    Exception = e
                });
            }
            finally
            {
                Locator.Instance.IsBusy = false;
            }
        }
 bool CanComplete(TodoItemViewModel todoItem)
 {
     return(true);
 }