本文整理汇总了C#中INotifyCollectionChanged类的典型用法代码示例。如果您正苦于以下问题:C# INotifyCollectionChanged类的具体用法?C# INotifyCollectionChanged怎么用?C# INotifyCollectionChanged使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
INotifyCollectionChanged类属于命名空间,在下文中一共展示了INotifyCollectionChanged类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollectionObserver
/// <summary>
/// Initializes a new instance of the <see cref="CollectionObserver"/> class.
/// </summary>
/// <param name="collection">The collection.</param>
/// <param name="tag">The tag.</param>
/// <param name="mementoService">The memento service.</param>
/// <exception cref="ArgumentNullException">The <paramref name="collection"/> is <c>null</c>.</exception>
public CollectionObserver(INotifyCollectionChanged collection, object tag = null, IMementoService mementoService = null)
: base(tag, mementoService)
{
Argument.IsNotNull("collection", collection);
_weakEventListener = this.SubscribeToWeakCollectionChangedEvent(collection, OnCollectionChanged);
}
示例2: Include
public void Include(INotifyCollectionChanged changed)
{
changed.CollectionChanged += (s, e) =>
{
var test = string.Format("{0}{1}{2}{3}{4}", e.Action, e.NewItems, e.NewStartingIndex, e.OldItems, e.OldStartingIndex);
};
}
示例3: CollectionChangeListener
/// <summary>
/// Constructor with collection and property name</summary>
/// <param name="collection">Collection whose changes are listened to</param>
/// <param name="propertyName">Property whose value change is listened to</param>
public CollectionChangeListener(INotifyCollectionChanged collection, string propertyName)
{
m_value = collection;
PropertyName = propertyName;
Subscribe();
}
示例4: ObserveCollection
/// <summary>
/// Begins observing the given notifying collection.
/// </summary>
/// <param name="notifyingCollection"></param>
public void ObserveCollection(INotifyCollectionChanged notifyingCollection)
{
notifyingCollection.ThrowIfNull ("notifyingCollection");
if (IsDisposed) return;
if (myObservedCollections.ContainsKey (notifyingCollection)) return;
myObservedCollections[notifyingCollection] = () => notifyingCollection.CollectionChanged -= myCollectionChangedEventHandler;
NotificationChainPropertyAttribute.CallProperties (notifyingCollection);
notifyingCollection.CollectionChanged += myCollectionChangedEventHandler;
var enumerable = notifyingCollection as IEnumerable;
if (enumerable != null)
{
foreach (var item in enumerable)
{
var inpc = item as INotifyPropertyChanged;
if (inpc != null)
base.Observe (inpc);
}
}
}
示例5: DetachNotificationEvents
private void DetachNotificationEvents(INotifyCollectionChanged notifyCollection)
{
if (notifyCollection != null)
{
notifyCollection.CollectionChanged -= OnCollectionChanged;
}
}
示例6: CollectionChangedEventListener
public CollectionChangedEventListener(INotifyCollectionChanged source, NotifyCollectionChangedEventHandler handler)
{
if (source == null) { throw new ArgumentNullException("source"); }
if (handler == null) { throw new ArgumentNullException("handler"); }
this.source = source;
this.handler = handler;
}
示例7: RemoveHandler
/// <summary>
/// Remove a handler for the given source's event.
/// </summary>
public static void RemoveHandler(INotifyCollectionChanged source, EventHandler<NotifyCollectionChangedEventArgs> handler)
{
if (handler == null)
throw new ArgumentNullException("handler");
CurrentManager.ProtectedRemoveHandler(source, handler);
}
示例8: CollectionObserver
public CollectionObserver(INotifyCollectionChanged collection, Action<NotifyCollectionChangedEventArgs> collectionChanged)
{
_collectionChanged = collectionChanged;
_collectionObserver = Observable.FromEventPattern<NotifyCollectionChangedEventHandler, NotifyCollectionChangedEventArgs>(
ev => collection.CollectionChanged += ev, ev => collection.CollectionChanged -= ev)
.Subscribe(e => CollectionChanged(e.EventArgs));
}
示例9: Capture
public Capture(ListBox listBox)
{
this.listBox = listBox;
incc = listBox.ItemsSource as INotifyCollectionChanged;
incc.CollectionChanged +=
new NotifyCollectionChangedEventHandler(incc_CollectionChanged);
}
示例10: CollectionSynchronizer
public CollectionSynchronizer(INotifyCollectionChanged source, ObservableCollection<object> target, IValueConverter valueConverter)
{
_source = source;
_target = target;
_valueConverter = valueConverter;
_source.CollectionChanged += OnSourceCollectionChanged;
}
示例11: UICollectionSynchronizer
private UICollectionSynchronizer(IList<CardViewModel> collection, INotifyCollectionChanged collectionChanged, StackLayout stackLayout, GamePageModel gamePageModel)
{
this.stackLayout = stackLayout;
this.gamePageModel = gamePageModel;
((INotifyCollectionChanged)collection).CollectionChanged += (object sender, NotifyCollectionChangedEventArgs e) => {
if (e.Action == NotifyCollectionChangedAction.Reset) {
this.stackLayout.Children.Clear ();
this.mapper.Clear ();
} else {
if(e.OldItems != null)
{
foreach (CardViewModel card in e.OldItems) {
this.RemoveItem(card);
}
}
if(e.NewItems != null)
{
foreach (CardViewModel card in e.NewItems) {
this.AddItem(card);
}
}
}
};
foreach (CardViewModel card in collection) {
this.AddItem (card);
}
}
示例12: CheckValueChanged
protected override SnapshotState CheckValueChanged(object newValue)
{
if (_listenedCollectionAsINotifyCollectionChanged != null &&
ReferenceEquals(_listenedCollectionAsINotifyCollectionChanged, newValue))
{
return this.State;
}
ReleaseListeners();
var newValueAsINotifyCollectionChanged = newValue as INotifyCollectionChanged;
var newValueAsIEnumerable = newValue as IEnumerable;
if (newValueAsINotifyCollectionChanged == null || newValueAsIEnumerable == null ||
newValue.GetType() != this.SnapshotValue.GetType())
{
return SnapshotState.CHANGED;
}
_listenedCollectionAsINotifyCollectionChanged = newValueAsINotifyCollectionChanged;
_listenedCollectionAsIEnumerable = newValueAsIEnumerable;
_listenedCollectionAsINotifyCollectionChanged.CollectionChanged += OnCollectionChanged;
return CheckCollectionChanged();
}
示例13: CollectionNotificationChainManager
public CollectionNotificationChainManager(INotifyCollectionChanged notifyingCollection)
: this()
{
notifyingCollection.ThrowIfNull ("notifyingCollection");
ObserveCollection (notifyingCollection);
}
示例14: UnhookCollectionChangedEvent
public static void UnhookCollectionChangedEvent(INotifyCollectionChanged collection, object target, PropertyInfo property)
{
_collectionPropertyMap
.Where(t => t.CollectionReference.Target == collection && t.TargetReference.Target == target && t.Property == property)
.ToList().ForEach(t => _collectionPropertyMap.Remove(t));
collection.CollectionChanged -= HandleCollectionChanged;
}
示例15: CollectionObserver
/// <summary>
/// Initializes a new instance of the <see cref="CollectionObserver"/> class.
/// </summary>
/// <param name="collection">The collection.</param>
/// <param name="tag">The tag.</param>
/// <param name="mementoService">The memento service.</param>
/// <exception cref="ArgumentNullException">The <paramref name="collection"/> is <c>null</c>.</exception>
public CollectionObserver(INotifyCollectionChanged collection, object tag = null, IMementoService mementoService = null)
: base(tag, mementoService)
{
Argument.IsNotNull("collection", collection);
_collection = collection;
_collection.CollectionChanged += OnCollectionChanged;
}