protected void RemoveItem() { var index = DisplayFileInfoList.IndexOf(SelectedFileInfo); FileInfoList.Remove(SelectedFileInfo); DisplayFileInfoList.Remove(SelectedFileInfo); //選択アイテムの更新 if (DisplayFileInfoList.Count == 0) { //表示対象がない index = -1; } else if (DisplayFileInfoList.Count <= index) { index = DisplayFileInfoList.Count - 1; } else { //何もしない } if (index >= 0) { DisplayFileInfoList.ElementAt(index).IsSelected = true; } //フィルタの更新 var missingKeywordList = new List <Extension>(); foreach (var item in ExtensionList) { missingKeywordList.Add(item); } missingKeywordList.RemoveAt(0); foreach (var item in DisplayFileInfoList) { var extension = Path.GetExtension(item.FilePath); var extensionItems = ExtensionList.Where(x => x.Name == extension); if (extensionItems.Any()) { foreach (var extItem in extensionItems) { missingKeywordList.Remove(extItem); } } } foreach (var item in missingKeywordList) { ExtensionList.Remove(item); } HasItem = FileInfoList.Any(); }