I have a ListView control as below
XAML
<ListView Name="myListView" MinHeight="200" FontSize="14" Style="{StaticResource DataGridStyle}">
<ListView.View>
<GridView>
<GridViewColumn Header="Reference Code" Width="0" DisplayMemberBinding="{Binding ReferenceCodeDescription}" HeaderContainerStyle="{StaticResource GridViewColumnHeaderStyle}"/>
<GridViewColumn Header="Description" Width="594" DisplayMemberBinding="{Binding Description}" />
</GridView>
</ListView.View>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
I have populated the ListView control with data using LINQ to Entities.
Code-Behind
Dim Stk As New List(Of Stock)
Dim Ref As New List(Of ReferenceCode)
Stk = Context.Stocks.ToList
Ref = Context.ReferenceCodes.ToList
Dim mySource = From s In Stk
Join r In Ref On s.StockID Equals r.StockID
Where s.Description.ToLower.Contains(txtSearch.Text.ToLower)
Select r.ReferenceCodeDescription, s.Description
myListView.ItemsSource = mySource
My question is how do I get a reference to individal GridViewColumn items from the SelectedItem property of the ListView ?
When I try
myListView.SelectedItem
I get the entire row back (E.g: {Reference Code = Z88 , Description = OIL FILTER}
I suspect that I am using an Anonymous type as my ItemsSource and that if I used a Named Type I may be able to interrogate the SelectedItem better, but I'm not sure how to do this.
Any ideas or advice?