using System.Collections.Generic; using System.Windows; using WpfApp1.Model; namespace WpfApp1 { public partial class MainWindow : Window { public IEnumerable 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 getGuitars(); } public class LocalDataProvider : IDataProvider { public IEnumerable 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", } }; } } } }