How do I update an IValueConverter on CollectionChanged?

后端 未结 4 1754
天涯浪人
天涯浪人 2020-12-20 22:13

Here\'s a basic example to explain my problem. Let\'s say I have

ObservableCollection Numbers {get; set;}

and an IValueConverte

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-20 22:51

    This is actually surprisingly very difficult. An IValueConverter doesn't update, so this does not work as you'd hope.

    I wrote a sample on the Microsoft Expression Gallery called Collection Aggregator that shows a working, if convoluted, approach to making this work via a Behavior that does the aggregation (Count, in your case, although I also support Sum, Average, etc) for you, instead of a converter.

提交回复
热议问题