MainWindow.xaml.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System.Collections.Generic;
  2. using System.Windows;
  3. using WpfApp1.Model;
  4. namespace WpfApp1
  5. {
  6. public partial class MainWindow : Window
  7. {
  8. public IEnumerable<Guitar> GuitarList { get; set; }
  9. public MainWindow()
  10. {
  11. InitializeComponent();
  12. DataContext = this;
  13. Globals.dataProvider = new LocalDataProvider();
  14. GuitarList = Globals.dataProvider.getGuitars();
  15. }
  16. private void ExitButton_Click(object sender, RoutedEventArgs e)
  17. {
  18. Application.Current.Shutdown();
  19. }
  20. class Globals
  21. {
  22. public static IDataProvider dataProvider;
  23. }
  24. interface IDataProvider
  25. {
  26. IEnumerable<Guitar> getGuitars();
  27. }
  28. public class LocalDataProvider : IDataProvider
  29. {
  30. public IEnumerable<Guitar> getGuitars()
  31. {
  32. return new Guitar[]
  33. {
  34. new Guitar
  35. {
  36. Brand = "Fender",
  37. Model = "Stratocaster",
  38. Color = "Black",
  39. },
  40. new Guitar
  41. {
  42. Brand = "Gibson",
  43. Model = "Les Paul",
  44. Color = "Sunburst",
  45. },
  46. new Guitar
  47. {
  48. Brand = "Martin",
  49. Model = "D-28",
  50. Color = "Natural",
  51. }
  52. };
  53. }
  54. }
  55. }
  56. }