I have a ListView bound to XML. The XAML looks like this:
<ListView Name="patientsListView" ItemsSource="{Binding}" SelectionChanged="patientsListView_SelectionChanged">
<ListView.View>
<GridView x:Name="patientGrid">
<GridViewColumn Header="PatientName" Width="Auto" DisplayMemberBinding="{Binding XPath=PatientName}" />
<GridViewColumn Header="PatientAccountNumber" Width="Auto" DisplayMemberBinding="{Binding XPath=PatientAccountNumber}" />
<GridViewColumn Header="DateOfBirth" Width="Auto" DisplayMemberBinding="{Binding XPath=DateOfBirth}" />
</GridView>
</ListView.View>
</ListView>
When a row is clicked, I want to do something:
private void patientsListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//do stuff
MessageBox.Show();
}
If I click on a row, how do I access a value in a column individually? When debugging, I can see in Locals in the listview SelectedItems that my data is in the the InnerText in the Results View for whatever index, but I don’t know how to get the value in code.
From there you can get
patient.PatientName, etc[EDIT] Now that I look at it, I’m not 100% sure this will work within a selectionchanged event. But it will work on a row click event.
However, if you’re just trying to update another part of the UI, you can do something like this: