I can not figure out how after Binding to get data from the filled fields. I read about two-way Binding , but this is not what I need. You just need to get the data for further storage in the database

 <ListView Name="lbTodoList" HorizontalContentAlignment="Stretch"> <ListBox.ItemTemplate> <DataTemplate> <Grid Margin="0,2"> <Grid.ColumnDefinitions> <ColumnDefinition Width="*" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <TextBlock Name="textmext" Grid.Column="0" Text="{Binding vopros}" /> <ComboBox Name="combo" Grid.Column="1" IsEditable="True" ItemsSource="{Binding otvet}" /> </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListView> 
  • Why two-way Binding is not what you need? And what specific data do you want to get? - VladD
  • For the ComboBox you need to bind the SelectedItem , this will be the selected answer. - Monk
  • @VladD two-way binding will change the data in the class, and I don’t need to change anything. You just need to get the Text from the TextBlock and the selected value from the ComboBox. You can get either in the array, or in any sheet - Andrew
  • You can retrieve data from the View by hand reading. This is contrary to MVVM (because VM should not know View), but if you do not use it, do what you want. If I were you, I would use two-way Binding (and if you don’t want to modify the data in object A , then do two-way Binding to object B ). - VladD

1 answer 1

A ListView should have a collection binding: <ListView ItemsSource="{Binding Items}"..

And here is the collection itself: public ObservableCollection<T> Items { get; set; } public ObservableCollection<T> Items { get; set; }