MainWindow.xaml.cs 1.1 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<Hero> HeroList { get; set; }
  11. public MainWindow()
  12. {
  13. InitializeComponent();
  14. DataContext = this;
  15. Globals.dataProvider = new LocalDataProvider();
  16. HeroList = 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<Hero> getPerson();
  26. }
  27. public class LocalDataProvider : IDataProvider
  28. {
  29. public IEnumerable<Hero> getPerson()
  30. {
  31. return new Hero[]{
  32. new Hero{
  33. race="Человек",
  34. name="Invoker"},
  35. new Hero{
  36. race="Огр",
  37. name="Orge Magi"},
  38. new Hero{
  39. race="Дракон",
  40. name="Viper"},
  41. };
  42. }
  43. }
  44. }