本文整理汇总了C#中BindableCollection.RemoveRange方法的典型用法代码示例。如果您正苦于以下问题:C# BindableCollection.RemoveRange方法的具体用法?C# BindableCollection.RemoveRange怎么用?C# BindableCollection.RemoveRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BindableCollection
的用法示例。
在下文中一共展示了BindableCollection.RemoveRange方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveRangeUsesDispatcherToRemoveElements
public void RemoveRangeUsesDispatcherToRemoveElements()
{
var itemsToRemove = new[] { new Element(), new Element() };
var existingItems = new[] { new Element() };
var collection = new BindableCollection<Element>(itemsToRemove.Concat(existingItems));
var dispatcher = new TestDispatcher();
Execute.Dispatcher = dispatcher;
collection.RemoveRange(itemsToRemove);
Assert.That(collection, Is.EquivalentTo(itemsToRemove.Concat(existingItems)));
Assert.NotNull(dispatcher.SendAction);
dispatcher.SendAction();
Assert.AreEqual(existingItems, collection);
}
示例2: when_RemoveRange_is_called_then_Reset_event_fired
public void when_RemoveRange_is_called_then_Reset_event_fired()
{
var testSchedulerProvider = new TestDispatcherSchedulerProvider();
var result = false;
var bindableCollection = new BindableCollection<int>(testSchedulerProvider);
var items = Enumerable.Range(0, 1).ToList();
bindableCollection.AddRange(items);
bindableCollection.CollectionChanged += (sender, args) =>
{
if (args.Action == NotifyCollectionChangedAction.Reset)
{
result = true;
}
};
bindableCollection.RemoveRange(items);
Assert.That(result, Is.True);
}
示例3: RemoveRangeFiresCollectionChangingBeforeRemovingItems
public void RemoveRangeFiresCollectionChangingBeforeRemovingItems()
{
var collection = new BindableCollection<Element>() { new Element() };
var changedEvents = new List<NotifyCollectionChangedEventArgs>();
collection.CollectionChanging += (o, e) =>
{
changedEvents.Add(e);
Assert.AreEqual(1, collection.Count);
};
collection.RemoveRange(new[] { new Element() });
Assert.AreEqual(1, changedEvents.Count);
var changedEvent = changedEvents[0];
Assert.AreEqual(NotifyCollectionChangedAction.Reset, changedEvent.Action);
}
示例4: RemoveRangeFiresCollectionChangedAfterRemovingItems
public void RemoveRangeFiresCollectionChangedAfterRemovingItems()
{
var itemsToRemove = new[] { new Element(), new Element() };
var collection = new BindableCollection<Element>(new[] { new Element() }.Concat(itemsToRemove));
var changedEvents = new List<NotifyCollectionChangedEventArgs>();
collection.CollectionChanged += (o, e) =>
{
Assert.AreEqual(1, collection.Count);
changedEvents.Add(e);
};
collection.RemoveRange(itemsToRemove);
Assert.AreEqual(1, changedEvents.Count);
var changedEvent = changedEvents[0];
Assert.AreEqual(NotifyCollectionChangedAction.Reset, changedEvent.Action);
}
示例5: RemoveRangeFiresPropertyChangedAfterRemovingItems
public void RemoveRangeFiresPropertyChangedAfterRemovingItems()
{
var itemsToRemove = new[] { new Element(), new Element() };
var collection = new BindableCollection<Element>(new[] { new Element() }.Concat(itemsToRemove));
var changedProperties = new List<string>();
((INotifyPropertyChanged)collection).PropertyChanged += (o, e) =>
{
Assert.AreEqual(1, collection.Count);
changedProperties.Add(e.PropertyName);
};
collection.RemoveRange(itemsToRemove);
Assert.That(changedProperties, Is.EquivalentTo(new[] { "Count", "Item[]" }));
}