当前位置: 首页>>代码示例>>C#>>正文


C# BindableCollection.RemoveRange方法代码示例

本文整理汇总了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);
        }
开发者ID:modulexcite,项目名称:Stylet,代码行数:18,代码来源:BindableCollectionTests.cs

示例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);
        }
开发者ID:ganesum,项目名称:Naru,代码行数:24,代码来源:BindableCollectionTests.cs

示例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);
        }
开发者ID:modulexcite,项目名称:Stylet,代码行数:17,代码来源:BindableCollectionTests.cs

示例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);
        }
开发者ID:modulexcite,项目名称:Stylet,代码行数:18,代码来源:BindableCollectionTests.cs

示例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[]" }));
        }
开发者ID:modulexcite,项目名称:Stylet,代码行数:16,代码来源:BindableCollectionTests.cs


注:本文中的BindableCollection.RemoveRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。