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


C# ObservableList.RemoveAt方法代码示例

本文整理汇总了C#中ObservableList.RemoveAt方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableList.RemoveAt方法的具体用法?C# ObservableList.RemoveAt怎么用?C# ObservableList.RemoveAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ObservableList的用法示例。


在下文中一共展示了ObservableList.RemoveAt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveItemAfterSubscribing

 public void RemoveItemAfterSubscribing()
 {
     var source = new ObservableList<ObservableList<string>>();
     ImmutableList<string> result = ImmutableList<string>.Empty;
     source.ToLiveLinq()
         .SelectMany((list, _) => list.ToLiveLinq())
         .ToObservableEnumerable().Subscribe(value => result = value);
     source.Add(new ObservableList<string>());
     source.RemoveAt(0);
     result.Should().BeEmpty();
 }
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:11,代码来源:SelectManyObservableCollectionTests.cs

示例2: DisposeSubscription_ThenRemoveItem

 public void DisposeSubscription_ThenRemoveItem()
 {
     var source = new ObservableList<ObservableList<string>>();
     ImmutableList<string> result = ImmutableList<string>.Empty;
     var subscription = source.ToLiveLinq()
         .SelectMany((list, _) => list.ToLiveLinq())
         .ToObservableEnumerable().Subscribe(value => result = value);
     source.Add(new ObservableList<string>());
     source.Add(new ObservableList<string>());
     source[0].Add("a");
     source[1].Add("c");
     subscription.Dispose();
     source.RemoveAt(1);
     result.Should().ContainInOrder("a", "c");
 }
开发者ID:ApocalypticOctopus,项目名称:Apocalyptic.Utilities.Net,代码行数:15,代码来源:SelectManyObservableCollectionTests.cs

示例3: ChangeCollection

 public void ChangeCollection()
 {
   _handle = new EventWaitHandle(false, EventResetMode.ManualReset);
   var test = new ObservableList<string>();
   test.Changed += List_Changed;
   test.Add("myValue");
   Assert.IsTrue(_handle.WaitOne(10), "Add() is not recognized as a change");
   _handle.Reset();
   test[0] = "newValue";
   Assert.IsTrue(_handle.WaitOne(10), "this[] is not recognized as a change");
   _handle.Reset();
   test.RemoveAt(0);
   Assert.IsTrue(_handle.WaitOne(10), "RemoveAt() is not recognized as a change");
   _handle.Reset();
   test.Add("myValue");
   Assert.IsTrue(_handle.WaitOne(10), "Add() is not recognized as a change");
   _handle.Reset();
   test.Remove("myValue");
   Assert.IsTrue(_handle.WaitOne(10), "Remove() is not recognized as a change");
 }
开发者ID:rnpowerconsulting,项目名称:appstract,代码行数:20,代码来源:ObservableListTests.cs

示例4: event_raised_when_item_is_removed_by_index

        public void event_raised_when_item_is_removed_by_index()
        {
            var testObject = new ObservableList<int>();

            var events = new List<NotifyCollectionChangedEventArgs>();

            testObject.Add(1);
            testObject.Add(2);
            testObject.Add(3);

            var itemRemoved = 2;

            testObject.CollectionChanged += (source, args) => events.Add(args);

            testObject.RemoveAt(1);

            Assert.Equal(1, events.Count);

            var ev = events[0];
            Assert.Equal(NotifyCollectionChangedAction.Remove, ev.Action);
            Assert.Equal(1, ev.OldItems.Count);
            Assert.Equal(itemRemoved, ev.OldItems[0]);
            Assert.Equal(1, ev.OldStartingIndex);
        }
开发者ID:ashleydavis,项目名称:Binding-System,代码行数:24,代码来源:ObservableListTests.cs

示例5: When_RemoveAt_Then_Action_Remove_Raised

        public void When_RemoveAt_Then_Action_Remove_Raised()
        {
            // Arrange
            var sut = new ObservableList<int>(new[] {10, 12, 18, 100});
            var results = new List<NotifyCollectionChangedEventArgs>();
            var expected = new[]
            {
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, 12, 1),
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, 100, 2),
            };
            sut.CollectionChanged += (o, e) => results.Add(e);

            // Act
            sut.RemoveAt(1);
            sut.RemoveAt(2);

            // Assert
            KKAssert.AreEqualByValue(expected, results);
        }
开发者ID:jonclare,项目名称:KodeKandy,代码行数:19,代码来源:Given_Observing_CollectionChanged_Events.cs

示例6: RemoveAt_FiresCollectionChanged

        public void RemoveAt_FiresCollectionChanged()
        {
            var list = new ObservableList<int> { 1, 2 };

            list.CollectionChanged += (sender, args) =>
            {
                Assert.AreEqual(NotifyCollectionChangedAction.Remove, args.Action);
                Assert.AreEqual(1, args.OldStartingIndex);
                Assert.IsTrue(new[] { 2 }.SequenceEqual(args.OldItems.Cast<int>()));
            };

            list.RemoveAt(1);
        }
开发者ID:mdabbagh88,项目名称:Rareform,代码行数:13,代码来源:ObservableListTest.cs

示例7: RemoveAtFiresListChangedEvent

        public void RemoveAtFiresListChangedEvent()
        {
            const string expectItem = "another string to remove";
            const int expectIndex = 1;
            var actualItem = "";
            var actualIndex = -1;

            var observableList = new ObservableList<string>(new[] { "Alpha", "Bravo", "Charlie", "Delta", "Echo" }.AsEnumerable());
            observableList.Insert(expectIndex, expectItem);
            observableList.ListChanged += (s, e) =>
                                              {
                                                  actualItem = e.Item;
                                                  actualIndex = e.Index;
                                              };
            observableList.RemoveAt(expectIndex);

            Assert.AreEqual(expectItem, actualItem);
            Assert.AreEqual(expectIndex, actualIndex);
        }
开发者ID:renangrativol,项目名称:DamienGKit,代码行数:19,代码来源:ObservableListTests.cs

示例8: TestRemoveAt

 public void TestRemoveAt()
 {
     var list = new List<string> { "aaa", "bbb", "ccc" };
     var set = new ObservableList<string>(list);
     Assert.AreEqual(set.Count, list.Count);
     bool propertyChangedInvoked = false;
     bool collectionChangedInvoked = false;
     set.PropertyChanged += (sender, e) =>
     {
         Assert.AreEqual(e.PropertyName, nameof(ObservableList<string>.Count));
         propertyChangedInvoked = true;
     };
     set.CollectionChanged += (sender, e) =>
     {
         Assert.AreEqual(e.Action, NotifyCollectionChangedAction.Remove);
         Assert.AreEqual(e.OldStartingIndex, 1);
         Assert.NotNull(e.OldItems);
         Assert.AreEqual(e.OldItems.Count, 1);
         Assert.AreEqual(e.OldItems[0], "bbb");
         collectionChangedInvoked = true;
     };
     set.RemoveAt(1);
     Assert.AreEqual(set.Count, 2);
     Assert.AreEqual(set[0], "aaa");
     Assert.AreEqual(set[1], "ccc");
     Assert.True(propertyChangedInvoked);
     Assert.True(collectionChangedInvoked);
 }
开发者ID:h78hy78yhoi8j,项目名称:xenko,代码行数:28,代码来源:TestObservableList.cs


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