/// <summary> /// Gets maximal selected index. /// </summary> /// <returns></returns> protected virtual int GetMaxSelectedIndex() { if (CollectionView == null) { return(-1); } var selectedList = CollectionView .AsParallel() .OfType <TItem>() .Where(x => x.IsSelected) .ToList(); if (selectedList.Count == 0) { return(-1); } var maxSelectedIndex = CollectionView.OfType <TItem>().ToList().IndexOf(selectedList[selectedList.Count - 1]); return(maxSelectedIndex); }