I have a ListView element in WPF as in the following:
<ListView Grid.Row="6" Margin="10" Name="ObservationsListView" SelectionChanged="ObservationsListView_SelectionChanged_1">
<ListView.View>
<GridView>
<GridViewColumn Header="Observation" Width="122" DisplayMemberBinding="{Binding observationStr}" />
<GridViewColumn Header="Value" Width="122" DisplayMemberBinding="{Binding valueStr}" />
<GridViewColumn Header="Hidden State" Width="122" DisplayMemberBinding="{Binding stateStr}" />
</GridView>
</ListView.View>
</ListView>
I am binding the following structure to it:
public struct ObservationStatePair
{
public AddressObservationGenerator.Observation observation { get; set; }
public AddressObservationGenerator.Observation state { get; set; }
public string observationStr { get; set; }
public string stateStr { get; set; }
public string valueStr { get; set; }
};
I set an array of ObservationStatePair s as the itemsSource of the ListView, which correctly changes its content as I wish. But additionally, I want to modify the "stateStr" field of the currently selected ObservationStatePair item of the ListView's itemsSource as needed. For this purpose, I do the following modification:
app.currentSequence[ObservationsListView.SelectedIndex].stateStr = selectedState;
ObservationsListView.ItemsSource = app.currentSequence;
ObservationsListView is my ListView here and currentSequence is the array of ObservationStatePair objects which I want to modify. But this update of the data source is not reflected in UI, the contents of the ListView does not change.
Am I missing something here? What should I do additionally in order to update the ListView's data source?