If each of your data items has an IsSelected
property that is bound to the ListViewItem.IsSelected
property, then you just iterate through your data to find the selected ones:
<ListView ItemsSource="{Binding Items}">
<ListView.ItemContainerStyle>
<Style TargetType="ListViewItem">
<Setter Property="IsSelected" Value="{Binding IsSelected}"/>
</Style>
</ListView.ItemContainerStyle>
</ListView>
And in your code:
public ICollection<DataItem> Items
{
get { return _items; }
}
public IEnumerable<DataItem> SelectedItems
{
get
{
foreach (var item in Items)
{
if (item.IsSelected)
yield return item;
}
}
}
private void DoSomethingWithSelectedItems()
{
foreach (var item in SelectedItems) ...
}
HTH,
Kent