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


C# ObservableCollectionEx.Add方法代码示例

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


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

示例1: ListViewModel

        public ListViewModel()
        {
            DataCollection = new ObservableCollectionEx<CmdArgItem>();
            DataCollectionView = CollectionViewSource.GetDefaultView(DataCollection);

            if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject()))
            {
                DataCollection.Add(new CmdArgItem() { Enabled = true, Command = @"C:\Users\Markus\Desktop\" });
                DataCollection.Add(new CmdArgItem() { Enabled = false, Command = "Hello World" });
                DataCollection.Add(new CmdArgItem() { Enabled = true, Command = "A very long commandline to test very long commandlines to see how very long commandlines work in our UI." });
            }
        }
开发者ID:MBulli,项目名称:SmartCommandlineArgs,代码行数:12,代码来源:ListViewModel.cs

示例2: BUG__0001__CollectionIsReadOnlyAfterInstanceCreated_NothingCanBeAdded

        public void BUG__0001__CollectionIsReadOnlyAfterInstanceCreated_NothingCanBeAdded()
        {
            var col = new ObservableCollectionEx<object>();
            col.Add(1);

            Assert.IsTrue(true);
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:7,代码来源:ObservableCollectionEx.bugfixes.cs

示例3: ObsCollExCollectionChangedTest

 public void ObsCollExCollectionChangedTest()
 {
     ObservableCollectionEx<string> target = new ObservableCollectionEx<string>();
     target.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(target_CollectionChanged);
     target.Add("Walter White");
     Assert.AreEqual(NotifyCollectionChangedAction.Add,_Args.Action);
     Assert.AreEqual(1, _Args.NewItems.Count);
     Assert.AreEqual("Walter White", _Args.NewItems[0]);
     _Args = null;
 }
开发者ID:PigDogBay,项目名称:MpdbSharedLibrary,代码行数:10,代码来源:ObservableCollectionExTest.cs

示例4: BUG__0002__BulkUpdateFailsWhenCalledFromMultipleThreads

        public void BUG__0002__BulkUpdateFailsWhenCalledFromMultipleThreads()
        {
            var col = new ObservableCollectionEx<int>();

            var t1 =
                Task.Factory.StartNew(() =>
                {
                    using (col.BeginBulkUpdate())
                    {
                        col.Add(1);
                        Thread.Sleep(10);
                    }
                });

            using (col.BeginBulkUpdate())
            {
                col.Clear();
            }

            // code above would normally fail by now.
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:21,代码来源:ObservableCollectionEx.bugfixes.cs

示例5: ParseTwitterResults

        private void ParseTwitterResults(XDocument doc, ObservableCollectionEx<TwitterStatusModel> feedModel)
        {
            foreach (TwitterStatusModel model in doc.Descendants("status").Select(BuildTwitterStatusl))
            {
                feedModel.Add(model);
            }

            if (!(App.isoSettings.Contains("Twitter")))
            {
                ThreadPool.QueueUserWorkItem(o => App.isoSettings.Add("Twitter", JsonHelpers.SerializeJson(feedModel)));
            }
            else
            {
                ThreadPool.QueueUserWorkItem(o => App.isoSettings["Twitter"] = JsonHelpers.SerializeJson(feedModel));
            }
        }
开发者ID:mtatto,项目名称:CanucksNews,代码行数:16,代码来源:TwitterService.cs

示例6: ObsCollExConstructorTest

 public void ObsCollExConstructorTest()
 {
     ObservableCollectionEx<string> target = new ObservableCollectionEx<string>();
     target.Add("Jesse Pinkman");
     Assert.AreEqual(1, target.Count);
     target.Clear();
     Assert.AreEqual(0, target.Count);
 }
开发者ID:PigDogBay,项目名称:MpdbSharedLibrary,代码行数:8,代码来源:ObservableCollectionExTest.cs

示例7: ObsCollExWPFTest

        public void ObsCollExWPFTest()
        {
            ObservableCollectionEx<string> target = new ObservableCollectionEx<string>();
            target.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(target_CollectionChanged);
            ListBox listBox = new ListBox();
            listBox.Name = "testListBox";
            listBox.ItemsSource = target;

            ManualResetEvent resetEvent = new ManualResetEvent(false);
            ThreadPool.QueueUserWorkItem(new WaitCallback((x) =>
            {
                target.Add("Hank Schrader");
                resetEvent.Set();
            }));
            resetEvent.WaitOne(1000);

            Assert.AreEqual(1, listBox.Items.Count);
            Assert.AreEqual("Hank Schrader", listBox.Items[0] as string);

            Assert.AreEqual(NotifyCollectionChangedAction.Add, _Args.Action);
            Assert.AreEqual(1, _Args.NewItems.Count);
            Assert.AreEqual("Hank Schrader", _Args.NewItems[0]);
        }
开发者ID:PigDogBay,项目名称:MpdbSharedLibrary,代码行数:23,代码来源:ObservableCollectionExTest.cs

示例8: ObsCollExWorkerThreadTest

 public void ObsCollExWorkerThreadTest()
 {
     ObservableCollectionEx<string> target = new ObservableCollectionEx<string>();
     target.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(target_CollectionChanged);
     ManualResetEvent resetEvent = new ManualResetEvent(false);
     ThreadPool.QueueUserWorkItem(new WaitCallback((x) =>
         {
             target.Add("Crystal Meth");
             resetEvent.Set();
         }));
     resetEvent.WaitOne(1000);
     Assert.AreEqual(NotifyCollectionChangedAction.Add, _Args.Action);
     Assert.AreEqual(1, _Args.NewItems.Count);
     Assert.AreEqual("Crystal Meth", _Args.NewItems[0]);
 }
开发者ID:PigDogBay,项目名称:MpdbSharedLibrary,代码行数:15,代码来源:ObservableCollectionExTest.cs


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