本文整理汇总了C#中ObservableCollection.AsBindable方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.AsBindable方法的具体用法?C# ObservableCollection.AsBindable怎么用?C# ObservableCollection.AsBindable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.AsBindable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStartup
protected override void OnStartup(StartupEventArgs e)
{
ObservableCollection<string> _strings = new ObservableCollection<string>();
object query = _strings.AsBindable().Count();
QueryVisualizerWindow window = new QueryVisualizerWindow(query);
this.MainWindow = window;
this.MainWindow.Show();
base.OnStartup(e);
}
示例2: SaleViewModel
public SaleViewModel()
{
_lineItems = new ObservableCollection<LineItem>();
_total = _lineItems.AsBindable()
.Sum(lineItem => lineItem.TotalPrice)
.Project(total => total * (1M + Discount / 100M))
.Switch()
.Case(total => total < 10M, total => 10M)
.Default(total => total)
.EndSwitch();
}
示例3: Page
public Page()
{
InitializeComponent();
_contacts = new ObservableCollection<Contact>();
_contacts.Add(new Contact() { Name = "Paul Stovell", Company = "Readify", PhoneNumber = "0421 938 793" });
_contacts.Add(new Contact() { Name = "Omar Besiso", Company = "Readify", PhoneNumber = "0421 938 793" });
_contacts.Add(new Contact() { Name = "Darren Neimke", Company = "Readify", PhoneNumber = "0421 938 793" });
_contacts.Add(new Contact() { Name = "Mitch Denny", Company = "Readify", PhoneNumber = "0421 938 793" });
_contacts.Add(new Contact() { Name = "Richard Banks", Company = "Readify", PhoneNumber = "0421 938 793" });
_contacts.Add(new Contact() { Name = "Andrew Matthews", Company = "Readify", PhoneNumber = "0421 938 793" });
_contactsList.ItemsSource = _contacts.AsBindable(Dispatcher)
.Where(c => c.Name.ToLower().StartsWith(this.FilterTextBox.Text.ToLower()))
.OrderBy(c => c.Name.ToLower());
_newItemPanel.DataContext = new Contact();
}
示例4: SumAggregatorCollectionChangeCausesRefresh
public void SumAggregatorCollectionChangeCausesRefresh()
{
var numbers = new ObservableCollection<object>();
numbers.AddRange(1, 2, 4);
var aggregator = numbers.AsBindable<object, int>().Sum();
var eventCatcher = new PropertyEventMonitor(aggregator);
Assert.AreEqual(1 + 2 + 4, aggregator.Current);
Assert.AreEqual(1, eventCatcher.Count);
// Test an Add
numbers.Add(8);
Assert.AreEqual(1 + 2 + 4 + 8, aggregator.Current);
Assert.AreEqual(2, eventCatcher.Count);
// Test a Remove
numbers.RemoveAt(0);
Assert.AreEqual(2 + 4 + 8, aggregator.Current);
Assert.AreEqual(3, eventCatcher.Count);
// Test a Replace
numbers[0] = 4;
Assert.AreEqual(4 + 4 + 8, aggregator.Current);
Assert.AreEqual(4, eventCatcher.Count);
// Test an AddRange
numbers.AddRange(4, 5);
Assert.AreEqual(4 + 4 + 8 + 4 + 5, aggregator.Current);
Assert.AreEqual(5, eventCatcher.Count);
// Test a replace with the same value - no events should be raised
numbers[0] = numbers[0];
Assert.AreEqual(4 + 4 + 8 + 4 + 5, aggregator.Current);
Assert.AreEqual(5, eventCatcher.Count);
// Test an add with 0
numbers.Add(0);
Assert.AreEqual(4 + 4 + 8 + 4 + 5, aggregator.Current);
Assert.AreEqual(5, eventCatcher.Count);
}