本文整理汇总了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." });
}
}
示例2: BUG__0001__CollectionIsReadOnlyAfterInstanceCreated_NothingCanBeAdded
public void BUG__0001__CollectionIsReadOnlyAfterInstanceCreated_NothingCanBeAdded()
{
var col = new ObservableCollectionEx<object>();
col.Add(1);
Assert.IsTrue(true);
}
示例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;
}
示例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.
}
示例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));
}
}
示例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);
}
示例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]);
}
示例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]);
}