Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## XAML
- <StackPanel>
- <ListBox IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}">
- <ListBox.ItemTemplate>
- <DataTemplate>
- <Label Content="{Binding Name}"/>
- </DataTemplate>
- </ListBox.ItemTemplate>
- </ListBox>
- <StackPanel>
- <Label>Name</Label>
- <TextBox Text="{Binding /Name}"/>
- <Label>Age</Label>
- <TextBox Text="{Binding /Age}"/>
- </StackPanel>
- </StackPanel>
- ## Code
- public partial class MainWindow : Window
- {
- public MainWindow()
- {
- InitializeComponent();
- var people = new ObservableCollection<Person>
- {
- new Person { Name = "Omar Abou Mrad", Age = 32 },
- new Person { Name = "John", Age = 10 }
- };
- this.DataContext = people;
- }
- }
Add Comment
Please, Sign In to add comment