I'm calling an api into a WPF listView. I added a CheckBox to each row and am trying to select a row the CheckBox and then display that value.
My xaml file:
<ListView x:Name="myListView"
SelectedValue="{Binding title}"
Height="550" Margin="35,149,-202.2,0"
VerticalAlignment="Top"
Background="AntiqueWhite" Grid.ColumnSpan="2"
SelectionChanged="MyListView_SelectionChanged">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" >
<CheckBox
Name="myCheckBox"
Click="listView_Click"
IsChecked="{Binding IsChecked}"
Margin="5, 0"/>
<TextBlock Text=" " />
<TextBlock Text="{Binding title}" />
<TextBlock Text=", " />
<TextBlock Text="{Binding publisher}" />
<TextBlock Text=", " />
<TextBlock Text="{Binding price}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
And my listView_Click method, with what I've tried and the output it produced
private void listView_Click(object sender, RoutedEventArgs e)
{
//Selected_label.Text = myListView.ItemsSource.ToString();
//Output = System.Collections.Generic.List`1[ShortBoxedUI.ShortBoxed+Comics]
//Selected_label.Text = myListView.Items.ToString();
//Output = System.Windows.Controls.ItemCollection
//Selected_label.Text = myListView.ToString();
//Output = System.Windows.Controls.ListView Items.Count:352
}
I checked the past questions/answers and didn't find anything that aligned with what I'm trying to do.