MainWindow.xaml.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Windows;
  2. using WpfApp2.model;
  3. namespace WpfApp2
  4. {
  5. /// <summary>
  6. /// Interaction logic for MainWindow.xaml
  7. /// </summary>
  8. public partial class MainWindow : Window
  9. {
  10. public IEnumerable<Product> ProductList { get; set; }
  11. public MainWindow()
  12. {
  13. InitializeComponent();
  14. DataContext = this;
  15. Globals.dataProvider = new LocalDataProvider();
  16. ProductList = Globals.dataProvider.getPerson();
  17. }
  18. private void ExitButton_Click(object sender, RoutedEventArgs e)
  19. {
  20. Application.Current.Shutdown();
  21. }
  22. }
  23. interface IDataProvider
  24. {
  25. IEnumerable<Product> getPerson();
  26. }
  27. public class LocalDataProvider : IDataProvider
  28. {
  29. public IEnumerable<Product> getPerson()
  30. {
  31. return new Product[]{
  32. new Product{
  33. name="Микрофон",
  34. model="NEUMANN TLM 102"},
  35. new Product{
  36. name="Мониторы",
  37. model="SoundStation A-6"},
  38. new Product{
  39. name="Звуковая карта",
  40. model="Focusrite Solo"},
  41. };
  42. }
  43. }
  44. }