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

C# NotifyCollectionChangedEventHandler类代码示例

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

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



NotifyCollectionChangedEventHandler类属于命名空间,在下文中一共展示了NotifyCollectionChangedEventHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: getFeeds

 /// <summary>
 /// Låter andra klasser lyssna på förändringar i repositoryt så att de kan uppdateras.
 /// </summary>
 /// <param name="handler"></param>
 /// <returns>Referns till en instans av FDRFeedRepository med eventhanterare</returns>
 public static IRepository<Feed> getFeeds(NotifyCollectionChangedEventHandler handler)
 {
     if (feeds == null)
         feeds = new FDRFeedRepository();
     feeds.CollectionChanged += handler;
     return feeds;
 }
开发者ID:goekboet,项目名称:FDR,代码行数:12,代码来源:DataConnection.cs


示例2: GeneratorNodeFactory

    public GeneratorNodeFactory( NotifyCollectionChangedEventHandler itemsChangedHandler,
                                 NotifyCollectionChangedEventHandler groupsChangedHandler,
                                 EventHandler<ExpansionStateChangedEventArgs> expansionStateChangedHandler,
                                 EventHandler isExpandedChangingHandler,
                                 EventHandler isExpandedChangedHandler,
                                 DataGridControl dataGridControl )
    {
      if( itemsChangedHandler == null )
        throw new ArgumentNullException( "itemsChangedHandler" );

      if( groupsChangedHandler == null )
        throw new ArgumentNullException( "groupsChangedHandler" );

      if( expansionStateChangedHandler == null )
        throw new ArgumentNullException( "expansionStateChangedHandler" );

      if( isExpandedChangingHandler == null )
        throw new ArgumentNullException( "isExpandedChangingHandler" );

      if( isExpandedChangedHandler == null )
        throw new ArgumentNullException( "isExpandedChangedHandler" );

      m_itemsChangedHandler = itemsChangedHandler;
      m_groupsChangedHandler = groupsChangedHandler;
      m_expansionStateChangedHandler = expansionStateChangedHandler;
      m_isExpandedChangingHandler = isExpandedChangingHandler;
      m_isExpandedChangedHandler = isExpandedChangedHandler;

      if( dataGridControl != null )
      {
        m_dataGridControl = new WeakReference( dataGridControl );
      }
    }
开发者ID:austinedeveloper,项目名称:WpfExtendedToolkit,代码行数:33,代码来源:GeneratorNodeFactory.cs


示例3: AddHandler

 public void AddHandler(NotifyCollectionChangedEventHandler handler)
 {
     if(handler != null)
     {
         _books.CollectionChanged += handler;
     }
 }
开发者ID:dmitriy1024,项目名称:HW_Collections,代码行数:7,代码来源:Library.cs


示例4: 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


示例5: OnAutoScrollToEndChanged

        public static void OnAutoScrollToEndChanged(DependencyObject s, DependencyPropertyChangedEventArgs e)
        {
            var ctrl = s as ItemsControl;
            if (ctrl == null)
                throw new InvalidOperationException("This attached property only supports ItemsControl or derived types.");

            var data = ctrl.Items as INotifyCollectionChanged;
            if (data == null)
                throw new InvalidOperationException("Collection does not support change notifications.");

            Control parentCtrl = ctrl;
            while (parentCtrl != null && parentCtrl.GetType() != typeof(ScrollViewer))
                parentCtrl = parentCtrl.Parent as Control;
            ScrollViewer sv = parentCtrl as ScrollViewer;

            var scrollToEndHandler = new NotifyCollectionChangedEventHandler(
                (s1, e1) =>
                {
                    if (e1.Action == NotifyCollectionChangedAction.Add && sv != null)
                        sv.ScrollToBottom();
                });

            if ((bool)e.NewValue)
                data.CollectionChanged += scrollToEndHandler;
            else
                data.CollectionChanged -= scrollToEndHandler;
        }
开发者ID:nabuk,项目名称:IstLight,代码行数:27,代码来源:ItemsControlHelper.cs


示例6: OnAutoScrollChanged

        public static void OnAutoScrollChanged(DependencyObject s, DependencyPropertyChangedEventArgs e)
        {
            var val = (bool)e.NewValue;
            var lb = s as ListView;
            if (lb == null)
                throw new InvalidOperationException("This behavior can only be attached to a ListView.");

            var ic = lb.Items;
            var data = ic.SourceCollection as INotifyCollectionChanged;
            if (data == null) return;

            var autoscroller = new NotifyCollectionChangedEventHandler(
                (s1, e1) =>
                {
                    var selectedItem = default(object);
                    switch (e1.Action)
                    {
                        case NotifyCollectionChangedAction.Add:
                        case NotifyCollectionChangedAction.Move: selectedItem = e1.NewItems[e1.NewItems.Count - 1]; break;
                        case NotifyCollectionChangedAction.Remove: if (ic.Count < e1.OldStartingIndex) { selectedItem = ic[e1.OldStartingIndex - 1]; } else if (ic.Count > 0) selectedItem = ic[0]; break;
                        case NotifyCollectionChangedAction.Reset: if (ic.Count > 0) selectedItem = ic[0]; break;
                    }

                    if (selectedItem == default(object)) return;
                    ic.MoveCurrentTo(selectedItem);
                    lb.ScrollIntoView(selectedItem);
                });

            if (val) data.CollectionChanged += autoscroller;
            else data.CollectionChanged -= autoscroller;
        }
开发者ID:VahidN,项目名称:PdfReport,代码行数:31,代码来源:AutoScrollListView.cs


示例7: OnAutoScrollToEndChanged

        public static void OnAutoScrollToEndChanged(DependencyObject s, DependencyPropertyChangedEventArgs e)
        {
            var listBox = s as ListBox;
            if(listBox==null)
                return;
            var listBoxItems = listBox.Items;
            var data = listBoxItems.SourceCollection as INotifyCollectionChanged;
            if (data == null)
                return;

            var scrollToEndHandler = new NotifyCollectionChangedEventHandler(
                (s1, e1) =>
                {
                    if (listBox.Items.Count <= 0) 
                        return;
                    var lastItem = listBox.Items[listBox.Items.Count - 1];
                    listBoxItems.MoveCurrentTo(lastItem);
                    listBox.ScrollIntoView(lastItem);
                });

            if ((bool)e.NewValue)
                data.CollectionChanged += scrollToEndHandler;
            else
                data.CollectionChanged -= scrollToEndHandler;
        }
开发者ID:BerserkerDotNet,项目名称:Unicorn.VisualStudio,代码行数:25,代码来源:ListBoxExtenders.cs


示例8: getCategories

 /// <summary>
 /// Låter andra klasser lyssna på förändringar i repositoryt så att de kan uppdateras.
 /// </summary>
 /// <param name="handler"></param>
 /// <returns>Referns till en instans av FDRCategoryRepository med eventhanterare</returns>
 public static IRepository<Category> getCategories(NotifyCollectionChangedEventHandler handler)
 {
     if (categories == null)
         categories = new FDRCategoryRepository();
     categories.CollectionChanged += handler;
     return categories;
 }
开发者ID:goekboet,项目名称:FDR,代码行数:12,代码来源:DataConnection.cs


示例9: 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


示例10: AddWeakEventListener

        /// <summary>
        /// Adds a weak event listener for a CollectionChanged event.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="handler">The event handler.</param>
        /// <exception cref="ArgumentNullException">source must not be <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException">handler must not be <c>null</c>.</exception>
        protected void AddWeakEventListener(INotifyCollectionChanged source, NotifyCollectionChangedEventHandler handler)
        {
            if (source == null) { throw new ArgumentNullException("source"); }
            if (handler == null) { throw new ArgumentNullException("handler"); }

            CollectionChangedEventListener listener = new CollectionChangedEventListener(source, handler);

            collectionChangedListeners.Add(listener);

            CollectionChangedEventManager.AddListener(source, listener);
        }
开发者ID:Kayomani,项目名称:FAP,代码行数:18,代码来源:Controller.cs


示例11: Subscribe

		private static void Subscribe(DataGrid dataGrid)
		{
			var handler = new NotifyCollectionChangedEventHandler((sender, eventArgs) => ScrollToEnd(dataGrid));
			if (handlersDict.ContainsKey(dataGrid))
			{
				return;
			}
            handlersDict.Add(dataGrid, handler);
			((INotifyCollectionChanged)dataGrid.Items).CollectionChanged += handler;
			ScrollToEnd(dataGrid);
		}
开发者ID:bchalek,项目名称:ZPOChat,代码行数:11,代码来源:DataGridBehavior.cs


示例12: SetupOnUnloadedHandler

 private static void SetupOnUnloadedHandler(DependencyObject dependencyObject, INotifyCollectionChanged observableCollection,
                                            NotifyCollectionChangedEventHandler sourceChangedHandler)
 {
     RoutedEventHandler unloadedEventHandler = null;
     unloadedEventHandler = (sender, args) =>
                                {
                                    observableCollection.CollectionChanged -= sourceChangedHandler;
                                    ((ListViewBase)sender).SelectionChanged -= OnGridSelectionChanged;
                                    ((ListViewBase)sender).Unloaded -= unloadedEventHandler;
                                };
     ((ListViewBase)dependencyObject).Unloaded += unloadedEventHandler;
 }
开发者ID:hyptechdev,项目名称:SubSonic8,代码行数:12,代码来源:MultipleSelectBehavior.cs


示例13: RemoveEventListener

        protected void RemoveEventListener(INotifyCollectionChanged source, NotifyCollectionChangedEventHandler handler)
        {
            if (source == null) { throw new ArgumentException("source"); }
            if (handler == null) { throw new ArgumentException("handler"); }

            CollectionChangedEventListener listener = collectionEventListeners.LastOrDefault(c => c.Source == source && c.Handler == handler);

            if (listener != null)
            {
                collectionEventListeners.Remove(listener);
                CollectionChangedEventManager.RemoveListener(source, listener);
            }
        }
开发者ID:hliang89,项目名称:BookLibrary,代码行数:13,代码来源:Controller.cs


示例14: DataMappingViewModel

        public DataMappingViewModel(IWebActivity activity, NotifyCollectionChangedEventHandler mappingCollectionChangedEventHandler = null)
        {
            _activity = activity;
            _actionManager = new ActionManager();
            Inputs = new ObservableCollection<IInputOutputViewModel>();
            Outputs = new ObservableCollection<IInputOutputViewModel>();

            if(mappingCollectionChangedEventHandler != null)
            {
                Inputs.CollectionChanged += mappingCollectionChangedEventHandler;
                Outputs.CollectionChanged += mappingCollectionChangedEventHandler;
            }
            Initialize(_activity);
        }
开发者ID:Robin--,项目名称:Warewolf,代码行数:14,代码来源:DataMappingViewModel.cs


示例15: Subscribe

        private static void Subscribe(DataGrid dataGrid)
        {
            if (infoDict.ContainsKey(dataGrid))
                return;

            var timer = new DispatcherTimer(DispatcherPriority.Background);
            var handler = new NotifyCollectionChangedEventHandler((sender, eventArgs) => timer.Start());

            infoDict.Add(dataGrid, new DataGridInfo(handler, timer));

            timer.Tick += (sender, args) => ScrollToEnd(dataGrid);
            ((INotifyCollectionChanged)dataGrid.Items).CollectionChanged += handler;
            
            timer.Start();
        }
开发者ID:mikel785,项目名称:Logazmic,代码行数:15,代码来源:DataGridBehavior.cs


示例16: HandleToolCollectionNotification

 internal void HandleToolCollectionNotification(NotifyCollectionChangedEventHandler listener, bool register)
 {
     if (null == listener)
     {
         throw FxTrace.Exception.ArgumentNull("listener");
     }
     if (register)
     {
         this.tools.CollectionChanged += listener;
     }
     else
     {
         this.tools.CollectionChanged -= listener;
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:15,代码来源:ToolboxCategory.cs


示例17: OnAutoScrollToEndChanged

        /// <summary>
        /// This method will be called when the AutoScrollToEnd
        /// property was changed
        /// </summary>
        /// <param name="s">The sender (the ListBox)</param>
        /// <param name="e">Some additional information</param>
        public static void OnAutoScrollToEndChanged(DependencyObject s, DependencyPropertyChangedEventArgs e)
        {
            var listView = s as ListView;
            if (listView != null)
            {
                var listViewItems = listView.Items;
                var data = listViewItems.SourceCollection as INotifyCollectionChanged;

                var scrollToEndHandler = new NotifyCollectionChangedEventHandler(
                    (s1, e1) =>
                        {
                            if (listView.Items.Count > 0 && e1 != null && e1.NewItems != null) // fix for error in certain conditions
                            {
                                //object lastItem = listView.Items[listView.Items.Count - 1];
                                var lastItem = e1.NewItems[0];
                                listView.Items.MoveCurrentTo(lastItem);
                                listView.ScrollIntoView(lastItem);
                                listView.SelectedItem = lastItem;
                            }
                        });

                var gotFocusHandler = new RoutedEventHandler (
                    (s2, e2) =>
                    {
                        if (listView.Items.Count > 0)
                        {
                            //object lastItem = listView.Items[listView.Items.Count - 1];
                            listView.ScrollIntoView(listView.SelectedItem);
                        }
                    });

                if ((bool)e.NewValue)
                {
                    if (data != null)
                    {
                        data.CollectionChanged += scrollToEndHandler;
                        listView.GotFocus += gotFocusHandler;
                    }
                }
                else if (data != null)
                {
                    data.CollectionChanged -= scrollToEndHandler;
                    listView.GotFocus -= gotFocusHandler;
                }
            }
        }
开发者ID:votrongdao,项目名称:DaxStudio,代码行数:52,代码来源:ListViewExtenders.cs


示例18: Advertisements_WhenNewItemAdded_CallsCollectionChangedEvent

        public void Advertisements_WhenNewItemAdded_CallsCollectionChangedEvent()
        {
            //	Arrange
            var paperVm = GetValidNewspaperItemViewModel();
            var adVm = GetValidAdvertisementItemViewModel();
            IList addedItems = new ArrayList();

            var collectionChangedEvent = new NotifyCollectionChangedEventHandler((sender, arg) => { addedItems = arg.NewItems; });
            paperVm.Advertisements.CollectionChanged += collectionChangedEvent;

            //	Act
            paperVm.Advertisements.Add(adVm);

            //	Assert
            addedItems.Count.Should().Be(1, "One item was added");
            adVm.Should().Be(addedItems[0]);
        }
开发者ID:jgartee,项目名称:PillarKata,代码行数:17,代码来源:NewspaperItem.UnitTests.cs


示例19: AssertChange

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        private static void AssertChange(
            ObservableCollection<int> original,
            Action<ObservableCollection<int>> change,
            ICollection copy,
            NotifyCollectionChangedEventHandler handler)
        {
            try
            {
                change(original);
                CollectionAssert.AreEqual(original, copy);
            }
            finally
            {
                original.CollectionChanged -= handler;
            }

            original.Add(42);
            CollectionAssert.AreNotEqual(original, copy);
        }
开发者ID:Lawo,项目名称:ember-plus-sharp,代码行数:21,代码来源:ObservableCollectionHelperTest.cs


示例20: OnIsAutoScrollChanged

        public static void OnIsAutoScrollChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            var value = (bool)e.NewValue;
            var listView = obj as ListView;
            var itemCollection = listView.Items;
            var data = (INotifyCollectionChanged)itemCollection;

            var autoscroller = new NotifyCollectionChangedEventHandler(
                (o, arg) =>
                {
                    var selectedItem = default(object);
                    switch (arg.Action)
                    {
                        case NotifyCollectionChangedAction.Add:
                        case NotifyCollectionChangedAction.Move:
                            {
                                selectedItem = arg.NewItems[arg.NewItems.Count - 1];
                                break;
                            }
                        case NotifyCollectionChangedAction.Remove:
                            {
                                if (itemCollection.Count < arg.OldStartingIndex)
                                {
                                    selectedItem = itemCollection[arg.OldStartingIndex - 1];
                                }
                                else if (itemCollection.Count > 0) selectedItem = itemCollection[0];
                                break;
                            }
                        case NotifyCollectionChangedAction.Reset:
                            {
                                if (itemCollection.Count > 0) selectedItem = itemCollection[0];
                                break;
                            }
                    }
                    if (selectedItem != default(object))
                    {
                        itemCollection.MoveCurrentTo(selectedItem);
                        listView.ScrollIntoView(selectedItem);
                    }
                });
            if (value) data.CollectionChanged += autoscroller;
            else data.CollectionChanged -= autoscroller;
        }
开发者ID:dragosIDL,项目名称:ShareApp,代码行数:43,代码来源:SelectorExtender.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# NotifyType类代码示例发布时间:2022-05-24
下一篇:
C# NotifyCollectionChangedAction类代码示例发布时间: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