• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# INotifyCollectionChanged类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中INotifyCollectionChanged的典型用法代码示例。如果您正苦于以下问题:C# INotifyCollectionChanged类的具体用法?C# INotifyCollectionChanged怎么用?C# INotifyCollectionChanged使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



INotifyCollectionChanged类属于命名空间,在下文中一共展示了INotifyCollectionChanged类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
开发者ID:jensweller,项目名称:Catel,代码行数:14,代码来源:CollectionObserver.cs


示例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);
     };
 }
开发者ID:Brinium,项目名称:ThreeColumnContainer,代码行数:7,代码来源:LinkerPleaseInclude.cs


示例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();
        }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:11,代码来源:CollectionChangedListener.cs


示例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);
                }
            }
        }
开发者ID:philchuang,项目名称:MvvmNotificationChainer,代码行数:29,代码来源:CollectionNotificationChainManager.cs


示例5: DetachNotificationEvents

 private void DetachNotificationEvents(INotifyCollectionChanged notifyCollection)
 {
     if (notifyCollection != null)
     {
         notifyCollection.CollectionChanged -= OnCollectionChanged;
     }
 }
开发者ID:Microsoft,项目名称:TVHelpers,代码行数:7,代码来源:Indicator.Items.cs


示例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;
 }
开发者ID:Kayomani,项目名称:FAP,代码行数:7,代码来源:CollectionChangedEventListener.cs


示例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);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:10,代码来源:CollectionChangedEventManager.cs


示例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));
 }
开发者ID:ryanhorath,项目名称:Rybird.Framework,代码行数:7,代码来源:CollectionObserver.cs


示例9: Capture

 public Capture(ListBox listBox)
 {
     this.listBox = listBox;
     incc = listBox.ItemsSource as INotifyCollectionChanged;
     incc.CollectionChanged +=
         new NotifyCollectionChangedEventHandler(incc_CollectionChanged);
 }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:7,代码来源:ListBoxBehavior.cs


示例10: CollectionSynchronizer

		public CollectionSynchronizer(INotifyCollectionChanged source, ObservableCollection<object> target, IValueConverter valueConverter)
		{
			_source = source;
			_target = target;
			_valueConverter = valueConverter;
			_source.CollectionChanged += OnSourceCollectionChanged;
		}
开发者ID:taliesins,项目名称:talifun-commander,代码行数:7,代码来源:CollectionSynchronizer.cs


示例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);
            }
        }
开发者ID:alanjg,项目名称:MajorDomo,代码行数:28,代码来源:UICollectionSynchronizer.cs


示例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();
        }
开发者ID:ruisebastiao,项目名称:WPF,代码行数:25,代码来源:ObservableCollectionSnapshot.cs


示例13: CollectionNotificationChainManager

        public CollectionNotificationChainManager(INotifyCollectionChanged notifyingCollection)
            : this()
        {
            notifyingCollection.ThrowIfNull ("notifyingCollection");

            ObserveCollection (notifyingCollection);
        }
开发者ID:philchuang,项目名称:MvvmNotificationChainer,代码行数:7,代码来源:CollectionNotificationChainManager.cs


示例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;
        }
开发者ID:oliverhanappi,项目名称:notifui,代码行数:8,代码来源:NotifyingCollectionHooker.cs


示例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;
        }
开发者ID:matthijskoopman,项目名称:Catel,代码行数:15,代码来源:CollectionObserver.cs


示例16: WeakCollectionChangedListener

 /// <summary>
 /// Initializes a new instance of the <see cref="WeakCollectionChangedListener"/>
 /// </summary>
 /// <param name="source">The source event source</param>
 /// <param name="listener">The listener event listener</param>
 private WeakCollectionChangedListener(
     INotifyCollectionChanged source,
     ICollectionChangedListener listener)
 {
     this._source = source;
     this._source.CollectionChanged += this.SourceCollectionChanged;
     this._weakListener = new WeakReference(listener);
 }
开发者ID:kouweizhong,项目名称:openair,代码行数:13,代码来源:WeakCollectionChangedListener.cs


示例17: AddListener

        //
        //  Public Methods 
        //

        /// <summary>
        /// Add a listener to the given source's event. 
        /// </summary>
        public static void AddListener(INotifyCollectionChanged source, IWeakEventListener listener) 
        { 
            if (source == null)
                throw new ArgumentNullException("source"); 
            if (listener == null)
                throw new ArgumentNullException("listener");

            CurrentManager.ProtectedAddListener(source, listener); 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:16,代码来源:CollectionChangedEventManager.cs


示例18: Capture

 public Capture(ListView ListView)
 {
     this.ListView = ListView;
     this.incc = ListView.ItemsSource as INotifyCollectionChanged;
     if (this.incc != null)
     {
         this.incc.CollectionChanged += this.incc_CollectionChanged;
     }
 }
开发者ID:dEMonaRE,项目名称:HearthstoneTracker,代码行数:9,代码来源:ListViewBehavior.cs


示例19: SetupCollectionChangedEventHandler

        private static NotifyCollectionChangedEventHandler SetupCollectionChangedEventHandler(DependencyObject dependencyObject,
                                                                                          INotifyCollectionChanged observableCollection)
        {
            NotifyCollectionChangedEventHandler sourceChangedHandler =
                (s, ev) => SelectedItemsCollectionChanged(dependencyObject, ev);
            observableCollection.CollectionChanged += sourceChangedHandler;

            return sourceChangedHandler;
        }
开发者ID:hyptechdev,项目名称:SubSonic8,代码行数:9,代码来源:MultipleSelectBehavior.cs


示例20: HookupToCollectionChanged

        /// <summary>
        /// Hookups the handler to the collection changed event. When the value changes it removes the handler.
        /// </summary>
        /// <param name="oldValue">The old collection.</param>
        /// <param name="newValue">The new collection.</param>
        /// <param name="handler">The handler to hookup.</param>
        public static void HookupToCollectionChanged(INotifyCollectionChanged oldValue, INotifyCollectionChanged newValue,
            NotifyCollectionChangedEventHandler handler)
        {
            if (oldValue != null)
                oldValue.CollectionChanged -= handler;

            if (newValue != null)
                newValue.CollectionChanged += handler;
        }
开发者ID:FoundOPS,项目名称:server,代码行数:15,代码来源:CollectionExtensions.cs



注:本文中的INotifyCollectionChanged类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# INotifyPropertyChanged类代码示例发布时间:2022-05-24
下一篇:
C# INotifyAction类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap