Advertisement
Guest User

Untitled

a guest
Aug 27th, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. public class Person
  2. {
  3. public string Name { get; set; }
  4.  
  5. public int Age { get; set; }
  6. }
  7.  
  8. public ObservableCollection<Person> Collection { get; set; }
  9.  
  10. public List<Person> Persons { get; set; }
  11.  
  12. private void WindowLoaded(object sender, RoutedEventArgs e)
  13. {
  14.  
  15. this.Persons = new List<Person>();
  16.  
  17. for (int i = 0; i != 35; i++)
  18. {
  19. this.Persons.Add(new Person() {Age = i, Name = i.ToString()});
  20. }
  21.  
  22. this.Collection = new ObservableCollection<Person>(this.Persons);
  23. }
  24.  
  25. <Grid DataContext="{Binding ElementName=TestWindow, Path=.}">
  26. <DataGrid x:Name="DataGrid" ItemsSource="{Binding Collection}" />
  27. </Grid>
  28.  
  29. <Grid DataContext="{Binding ElementName=TestWindow, Path=.}">
  30. <DataGrid x:Name="DataGrid" ItemsSource="{Binding Persons}" />
  31. </Grid>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement