Guest User

Untitled

a guest
Jan 22nd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. ## XAML
  2.  
  3. <StackPanel>
  4. <ListBox IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}">
  5. <ListBox.ItemTemplate>
  6. <DataTemplate>
  7. <Label Content="{Binding Name}"/>
  8. </DataTemplate>
  9. </ListBox.ItemTemplate>
  10. </ListBox>
  11. <StackPanel>
  12. <Label>Name</Label>
  13. <TextBox Text="{Binding /Name}"/>
  14. <Label>Age</Label>
  15. <TextBox Text="{Binding /Age}"/>
  16. </StackPanel>
  17. </StackPanel>
  18.  
  19. ## Code
  20.  
  21. public partial class MainWindow : Window
  22. {
  23. public MainWindow()
  24. {
  25. InitializeComponent();
  26.  
  27. var people = new ObservableCollection<Person>
  28. {
  29. new Person { Name = "Omar Abou Mrad", Age = 32 },
  30. new Person { Name = "John", Age = 10 }
  31. };
  32.  
  33. this.DataContext = people;
  34. }
  35. }
Add Comment
Please, Sign In to add comment