WPF: How do I hook into a ListView's ItemsSource CollectionChanged notification?

前端 未结 3 662
感动是毒
感动是毒 2021-01-18 06:29

I have a ListView that is databound to an ObservableCollection ...



        
3条回答
  •  余生分开走
    2021-01-18 07:00

    you are going to have to attach the handler to your list. Or, use a CollectionView and hook the changed event there.

    in your codebehind, do like this:

    MyList.CollectionChanged += new NotifyCollectionChangedEventHandler( this.MyCollectionChanged );
    
    
    private void SortCollectionChanged( object sender, NotifyCollectionChangedEventArgs e )
    {
      Debug.WriteLine( "Changed" );
    }
    

提交回复
热议问题