本文整理汇总了C#中System.Collections.ObservableCollection.AsBindable方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.AsBindable方法的具体用法?C# ObservableCollection.AsBindable怎么用?C# ObservableCollection.AsBindable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.AsBindable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Trace.Listeners.Add(new ConsoleTraceListener());
Console.Write("Generating test items... ");
var contacts = new ObservableCollection<Contact>();
for (var i = 0; i < ItemsInQuery; i++)
{
contacts.Add(new Contact {FirstName = "Paul " + i, LastName = "Stovell " + i});
}
Console.WriteLine("Done.");
Test("Select",
() => System.Linq.Enumerable.Select(contacts, c => c.FirstName),
() => contacts.AsBindable().Select(c => c.FirstName, DependencyDiscovery.Disabled)
);
Test("Select Anonymous",
() => System.Linq.Enumerable.Select(contacts, c => new { Name = c.FirstName + c.LastName }),
() => contacts.AsBindable().Select(c => new { Name = c.FirstName + c.LastName }, DependencyDiscovery.Disabled)
);
Test("Where",
() => System.Linq.Enumerable.Where(contacts, c => c.FirstName.Contains("3")),
() => contacts.AsBindable().Where(c => c.FirstName.Contains("3"), DependencyDiscovery.Disabled)
);
Test("OrderBy",
() => System.Linq.Enumerable.OrderBy(contacts, c => c.FirstName.Substring(4, 1)),
() => contacts.AsBindable().OrderBy(c => c.FirstName.Substring(4, 1), DependencyDiscovery.Disabled)
);
Console.WriteLine("Complete");
Console.ReadKey();
}