In WPF app I have a ListView which is connected with ObservableCollection ShQuCollection
through databinding:
<ListView Name="ShSelList" ItemsSource="{Binding Source={StaticResource myDataSource},Path=ShQuCollection}" SelectionChanged="ShSelList_SelectionChanged">
<ListView.View>
<GridView>
<GridViewColumn Header="Code" DisplayMemberBinding="{Binding StrCode}"/>
<GridViewColumn Header="Date" DisplayMemberBinding="{Binding Date}"/>
<GridViewColumn Header="Time" DisplayMemberBinding="{Binding Time}"/>
</GridView>
</ListView.View>
</ListView>
From inside ListView SelectionChanged event handler I need to call a method and pass to it a string parameter, taking it from one of the field of the selected row of the ObservableCollection ShQuCollection
.
How I could reference the ObservableCollection from inside ListView SelectionChanged event handler?
private void ShSelList_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
...?????
}
Edited (added):
My ObservableCollection is in code-behind file of another window and I use Window.Resources
declaration to reach it.
<Window.Resources>
<c:ShWindow x:Key="myDataSource"/>
</Window.Resources>
And ObservableCollection looks like:
ObservableCollection<ShsQu> _ShQuCollection =
new ObservableCollection<ShsQu>();
public ObservableCollection<ShsQu> ShQuCollection
{ get { return _ShQuCollection; } }
public class ShsQu
{
public string StrCode { get; set; }
public string Date { get; set; }
public string Time { get; set; }
}