12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using System.Collections.Generic;
- using System.Windows;
- using WpfApp1.Model;
- namespace WpfApp1
- {
- public partial class MainWindow : Window
- {
- public IEnumerable<Guitar> GuitarList { get; set; }
- public MainWindow()
- {
- InitializeComponent();
- DataContext = this;
- Globals.dataProvider = new LocalDataProvider();
- GuitarList = Globals.dataProvider.getGuitars();
- }
- private void ExitButton_Click(object sender, RoutedEventArgs e)
- {
- Application.Current.Shutdown();
- }
- class Globals
- {
- public static IDataProvider dataProvider;
- }
- interface IDataProvider
- {
- IEnumerable<Guitar> getGuitars();
- }
- public class LocalDataProvider : IDataProvider
- {
- public IEnumerable<Guitar> getGuitars()
- {
- return new Guitar[]
- {
- new Guitar
- {
- Brand = "Fender",
- Model = "Stratocaster",
- Color = "Black",
- },
- new Guitar
- {
- Brand = "Gibson",
- Model = "Les Paul",
- Color = "Sunburst",
- },
- new Guitar
- {
- Brand = "Martin",
- Model = "D-28",
- Color = "Natural",
- }
- };
- }
- }
- }
- }
|