DeckViewEdit.xaml.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Documents;
  8. using System.Windows.Input;
  9. using System.Windows.Media;
  10. using System.Windows.Media.Animation;
  11. using System.Windows.Shapes;
  12. using Microsoft.Phone.Shell;
  13. using VocabManager.ViewModel;
  14. namespace VocabManager.View
  15. {
  16. public partial class DeckViewEdit : UserControlBase
  17. {
  18. ApplicationBarIconButton _cancel;
  19. ApplicationBarIconButton _save;
  20. DeckViewModel _deckViewModel;
  21. public DeckViewEdit()
  22. {
  23. InitializeComponent();
  24. _cancel = new ApplicationBarIconButton(new Uri(IconUrls.Cancel, UriKind.Relative));
  25. _cancel.Click += new EventHandler(_cancel_Click);
  26. _cancel.Text = "cancel";
  27. _save = new ApplicationBarIconButton(new Uri(IconUrls.Save, UriKind.Relative));
  28. _save.Text = "save";
  29. _save.Click += new EventHandler(_save_Click);
  30. }
  31. void _save_Click(object sender, EventArgs e)
  32. {
  33. _deckViewModel.SaveCommand.Execute(null);
  34. }
  35. void _cancel_Click(object sender, EventArgs e)
  36. {
  37. _deckViewModel.CancelEditCommand.Execute(null);
  38. }
  39. protected override void OnLoad()
  40. {
  41. base.OnLoad();
  42. _deckViewModel = this.DataContext as DeckViewModel;
  43. StoreAppBarButtons();
  44. ContainerPage.ApplicationBar.Buttons.Clear();
  45. ContainerPage.ApplicationBar.Buttons.Add(_save);
  46. ContainerPage.ApplicationBar.Buttons.Add(_cancel);
  47. }
  48. }
  49. }