本文整理汇总了C#中BindableCollection.Refresh方法的典型用法代码示例。如果您正苦于以下问题:C# BindableCollection.Refresh方法的具体用法?C# BindableCollection.Refresh怎么用?C# BindableCollection.Refresh使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BindableCollection
的用法示例。
在下文中一共展示了BindableCollection.Refresh方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: when_Refresh_is_called_then_Reset_event_fired
public void when_Refresh_is_called_then_Reset_event_fired()
{
var testSchedulerProvider = new TestDispatcherSchedulerProvider();
var result = false;
var bindableCollection = new BindableCollection<int>(testSchedulerProvider);
var items = Enumerable.Range(0, 1).ToList();
bindableCollection.AddRange(items);
bindableCollection.CollectionChanged += (sender, args) =>
{
if (args.Action == NotifyCollectionChangedAction.Reset)
{
result = true;
}
};
bindableCollection.Refresh();
Assert.That(result, Is.True);
}
示例2: RefreshFiresCollectionChanged
public void RefreshFiresCollectionChanged()
{
var collection = new BindableCollection<Element>(new[] { new Element() });
var changedEvents = new List<NotifyCollectionChangedEventArgs>();
collection.CollectionChanged += (o, e) => changedEvents.Add(e);
collection.Refresh();
Assert.AreEqual(1, changedEvents.Count);
var changedEvent = changedEvents[0];
Assert.AreEqual(NotifyCollectionChangedAction.Reset, changedEvent.Action);
}
示例3: RefreshUsesDispatcherToFireEvents
public void RefreshUsesDispatcherToFireEvents()
{
var collection = new BindableCollection<Element>();
bool propertyChangedRaised = false;
((INotifyPropertyChanged)collection).PropertyChanged += (o, e) => propertyChangedRaised = true;
bool collectionChangingRaised = false;
collection.CollectionChanging += (o, e) => collectionChangingRaised = true;
bool collectionChangedRaised = false;
collection.CollectionChanged += (o, e) => collectionChangedRaised = true;
var dispatcher = new TestDispatcher();
Execute.Dispatcher = dispatcher;
collection.Refresh();
Assert.False(propertyChangedRaised);
Assert.False(collectionChangingRaised);
Assert.False(collectionChangedRaised);
Assert.NotNull(dispatcher.SendAction);
dispatcher.SendAction();
Assert.True(propertyChangedRaised);
Assert.True(collectionChangingRaised);
Assert.True(collectionChangedRaised);
}
示例4: RefreshFiresPropertyChanged
public void RefreshFiresPropertyChanged()
{
var collection = new BindableCollection<Element>(new[] { new Element() });
var changedProperties = new List<string>();
((INotifyPropertyChanged)collection).PropertyChanged += (o, e) => changedProperties.Add(e.PropertyName);
collection.Refresh();
Assert.That(changedProperties, Is.EquivalentTo(new[] { "Count", "Item[]" }));
}