Property Changed in DependencyProperty

后端 未结 4 858
臣服心动
臣服心动 2020-12-07 04:37

In a previous post I asked how to register a property as DependencyProperty. I got an answer and it works fine.

But now I want to add some Items to this DependencyP

4条回答
  •  [愿得一人]
    2020-12-07 05:04

    OnChartEntriesChanged callback will be called when you will set the new instance of the ObservableCollection. You will have to listen to collection changed as below:

        private static void OnChartEntriesChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            ((ObservableCollection)e.OldValue).CollectionChanged -= new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ChartView_CollectionChanged);   
            ((ObservableCollection)e.NewValue).CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ChartView_CollectionChanged);   
        }
    
        static void ChartView_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
    
        }
    

提交回复
热议问题