本文整理汇总了C#中ObservableList.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableList.IndexOf方法的具体用法?C# ObservableList.IndexOf怎么用?C# ObservableList.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableList
的用法示例。
在下文中一共展示了ObservableList.IndexOf方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ChangeItem
public void ChangeItem()
{
_handle = new EventWaitHandle(false, EventResetMode.ManualReset);
var test = new ObservableList<string>();
test.Add("myValue");
test.ItemChanged += List_ItemEvent;
test[test.IndexOf("myValue")] = "myNewValue";
Assert.IsTrue(_handle.WaitOne(10));
}
示例2: IndexOfReturnsCorrectIndex
public void IndexOfReturnsCorrectIndex()
{
var list = new List<short> { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 };
var observableList = new ObservableList<short>(list);
foreach (var value in list)
Assert.AreEqual(list.IndexOf(value), observableList.IndexOf(value));
}
示例3: IndexOfGivenUncontainedValueReturnsMinusOne
public void IndexOfGivenUncontainedValueReturnsMinusOne()
{
const string uncontainedValue = "Charly";
var observableList = new ObservableList<string>(new[] { "Alpha", "Bravo", "Charlie", "Delta", "Echo" }.AsEnumerable());
Assert.AreEqual(-1, observableList.IndexOf(uncontainedValue));
}
示例4: IndexOfGivenContainedValueReturnsCorrectIndex
public void IndexOfGivenContainedValueReturnsCorrectIndex()
{
const string containedValue = "Charlie";
const int expectedIndex = 2;
var observableList = new ObservableList<string>(new[] { "Alpha", "Bravo", containedValue, "Delta", "Echo" }.AsEnumerable());
Assert.AreEqual(expectedIndex, observableList.IndexOf(containedValue));
}
示例5: TestIndexOf
public void TestIndexOf()
{
var list = new List<string> { "aaa", "bbb", "ccc" };
var set = new ObservableList<string>(list);
Assert.AreEqual(set.IndexOf("aaa"), 0);
Assert.AreEqual(set.IndexOf("bbb"), 1);
Assert.AreEqual(set.IndexOf("ccc"), 2);
Assert.AreEqual(set.IndexOf("ddd"), -1);
set.Add("ddd");
Assert.AreEqual(set.IndexOf("ddd"), 3);
set.Remove("bbb");
Assert.AreEqual(set.IndexOf("bbb"), -1);
Assert.AreEqual(set.IndexOf("ddd"), 2);
}