private void Add_OnClick(object sender, RoutedEventArgs e) { MemoItem memoItem = new MemoItem(); memoItem.DateCreated = DateTime.Now; memoItem.Text = ""; memoItem.Title = ""; var viewModel = (MemoPageViewModel)this.DataContext; viewModel.MemoItems.Add(memoItem); viewModel.AddMemoItem = memoItem; viewModel.AddCommand.Execute(null); viewModel.RefreshCommand.Execute(null); }
private void MasterListView_ItemClick(object sender, ItemClickEventArgs e) { var clickedItem = (MemoItem)e.ClickedItem; _lastSelectedItem = clickedItem; var viewModel = (MemoPageViewModel)this.DataContext; if (AdaptiveStates.CurrentState == NarrowState) { //Frame.Navigate(typeof(MemoDetailPage), e.ClickedItem as MemoItem, new DrillInNavigationTransitionInfo()); viewModel.SetCommand.Execute(Frame); viewModel.OpenToMemoDetailPageCommand.Execute(e.ClickedItem as MemoItem); } else { //DetailFrame.Navigate(typeof(MemoDetailPage), e.ClickedItem as MemoItem, new DrillInNavigationTransitionInfo()); viewModel.SetCommand.Execute(DetailFrame); viewModel.OpenToMemoDetailPageCommand.Execute(e.ClickedItem as MemoItem); } }
private void Save_OnClick(object sender, RoutedEventArgs e) { if (MasterListView.SelectedItem != null) { var viewModel = (MemoPageViewModel)this.DataContext; var item1 = MasterListView.SelectedItem; var Item = MasterListView.SelectedItem as MemoItem ?? _lastSelectedItem; viewModel.ChangeMemoItem = Item; viewModel.ChangeCommand.Execute(Item.Id); viewModel.RefreshCommand.Execute(null); int index = 0; foreach (MemoItem memoItem in viewModel.MemoItems) { if (memoItem.Id == Item.Id) { MasterListView.SelectedItem = memoItem; _lastSelectedItem = memoItem; viewModel.OpenToMemoDetailPageCommand.Execute(_lastSelectedItem); break; } } } }