当前位置: 首页>>代码示例>>C#>>正文


C# NotifyCollectionChangedEventHandler类代码示例

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


NotifyCollectionChangedEventHandler类属于命名空间,在下文中一共展示了NotifyCollectionChangedEventHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ItemsSourceCollectionViewSource

 public ItemsSourceCollectionViewSource([NotNull] UICollectionView collectionView,
     string itemTemplate = AttachedMemberConstants.ItemTemplate)
     : base(collectionView, itemTemplate)
 {
     _weakHandler = ReflectionExtensions.MakeWeakCollectionChangedHandler(this,
         (adapter, o, arg3) => adapter.OnCollectionChanged(o, arg3));
 }
开发者ID:dbeattie71,项目名称:MugenMvvmToolkit,代码行数:7,代码来源:ItemsSourceCollectionViewSource.cs


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