I have problem in ListView MultiSelection.
Here is my code :
private ICommand _excludeCurveCommand;
public ICommand ExcludeCurveCommand
{
get
{
if (_excludeCurveCommand == null)
_excludeCurveCommand = new DelegateCommand<object>(param => this.ExcludeCurveExecuted(param));
return _excludeCurveCommand;
}
}
/// <summary>
/// Executed event for ContextMenu --> Remove click
/// </summary>
/// <param name="param">param is FolderItemViewModel bound as CommandParameter</param>
private void ExcludeCurveExecuted(object param)
{
ICollection<object> curves = param as ICollection<object>;
int count = curves.Count;
}
< Button Content="Exclude" Command="{Binding ExcludeCurveCommand}" CommandParameter="{Binding SelectedItems,ElementName=lstView}" .../>
< ListView Name="lstView" ItemsSource="{Binding MyList}" SelectionMode="Extended" ..../>
Here i used shift and selected from first four items. But in ExcludeCurveExecuted method i getting some random counts always. What is the issue in this.
EDIT:
* I don’t wantto go with IsSelected flag in ViewModel
To me it seems that you have have
ListViewUI virtualization enabled, as it enabled by default. That means, thatListViewdraws only items visible on UI.Here is MSDN link
To be sure what is going on interface (like selection in your case) I’m afraid you don’t have any other option then
or disable UI virtualization (not good)
or implement
IsSelectedflag on ModelViewGood luck.