Catalog.xaml.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using examPrepare.ViewModels;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Navigation;
  15. using System.Windows.Shapes;
  16. namespace examPrepare.Pages
  17. {
  18. /// <summary>
  19. /// Interaction logic for Catalog.xaml
  20. /// </summary>
  21. public partial class Catalog : Page
  22. {
  23. public CatalogViewModel catalogData = new CatalogViewModel();
  24. public Catalog()
  25. {
  26. InitializeComponent();
  27. DataContext = catalogData;
  28. }
  29. private void Button_Click(object sender, RoutedEventArgs e)
  30. {
  31. Button btn = (Button)sender;
  32. string id = btn.Uid;
  33. if (GlobalInfo.cart.Any(item => item.Key == id))
  34. {
  35. GlobalInfo.cart[id]++;
  36. } else
  37. {
  38. GlobalInfo.cart[id] = 1;
  39. }
  40. GlobalInfo.setUpProductCountFunc();
  41. }
  42. }
  43. }