本文整理汇总了C#中WpfApplication1.List.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# List.Contains方法的具体用法?C# List.Contains怎么用?C# List.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WpfApplication1.List
的用法示例。
在下文中一共展示了List.Contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: selectedCellsChangedHandler
private void selectedCellsChangedHandler(object param = null)
{
IEnumerable<object> selected = param as IEnumerable<object>;
var selectedDataItems = selected.Cast<DataItemViewModel>().ToList();
// Clone the SelectedEntries
List<DataItemViewModel> clonedSelectedEntries = new List<DataItemViewModel>(selectedDataItems);
// keep the previous entry that is part of the selection
DataItemViewModel previousSelectedItem = null;
// Keep the previous entry that is in the list
DataItemViewModel previousItem = null;
// build list backwards so that diffs happen in order going up
int viewCount = Data.Count;
for (int i = viewCount - 1; i >= 0; i--)
{
// Get current item in the list
var currentItem = Data[i] as DataItemViewModel;
// If the item is part of the selection we will want some kind of diff
if (clonedSelectedEntries.Contains(currentItem))
{
// If the previous selected item is null
// this means that it is the bottom most item in the selection
// and compare it to the previous non selected string
if (previousSelectedItem != null)
{
currentItem.PrevName = previousSelectedItem.Name;
currentItem.IsVisualDiffVisible = true;
}
else if (previousItem != null) // if there is a previous selected item compare the item with that one
{
currentItem.PrevName = previousItem.Name;
currentItem.IsVisualDiffVisible = true;
}
else //the selected item is the bottom item with nothing else to compare, so just show differences from an empty string
{
currentItem.PrevName = String.Empty;
currentItem.IsVisualDiffVisible = true;
}
// Set the previously selected item to the current item to keep for comparison with the next selected item on the way up
previousSelectedItem = currentItem;
// clean up
clonedSelectedEntries.Remove(currentItem);
}
else // if item is not part of the selection we will want the original text
{
currentItem.PrevName = String.Empty;
currentItem.IsVisualDiffVisible = false;
}
// regardless of whether item is in selection or not we keep it as the previous item when we move up to the next one
previousItem = currentItem;
}
}