/// <summary> /// Override OnNavigatedTo. /// Author: ChuyangLiu /// </summary> protected override void OnNavigatedTo(NavigationEventArgs e) { EditTodoPageViewModel vm = e.Parameter as EditTodoPageViewModel; if (e != null) { ViewModel = vm; } else { ViewModel = new EditTodoPageViewModel(); } // Update delete button visibility if (ViewModel.TodoItem == null) { deleteBtn.Visibility = Visibility.Collapsed; ShareBtn.Visibility = Visibility.Collapsed; UpdateTileBtn.Visibility = Visibility.Collapsed; } else { deleteBtn.Visibility = Visibility.Visible; ShareBtn.Visibility = Visibility.Visible; UpdateTileBtn.Visibility = Visibility.Visible; } //Add event handler dtm = DataTransferManager.GetForCurrentView(); dtm.DataRequested += dtm_DataRequested; }
/// <summary> /// Add button click event. /// Author: ChuyangLiu /// </summary> private void AddButton_Click(object sender, RoutedEventArgs e) { EditTodoPageViewModel vm = new EditTodoPageViewModel { TodoItem = null, Year = ViewModel.Year, Month = ViewModel.Month, Day = ViewModel.Day }; Frame.Navigate(typeof(EditTodoPage), vm); }
private void ListView_ItemClick(object sender, ItemClickEventArgs e) { TodoItem item = e.ClickedItem as TodoItem; EditTodoPageViewModel vm = new EditTodoPageViewModel { TodoItem = item, Year = ViewModel.Year, Month = ViewModel.Month, Day = ViewModel.Day }; Frame.Navigate(typeof(EditTodoPage), vm); }