Convert List to ObservableCollection in WP7

后端 未结 10 907
不知归路
不知归路 2020-12-25 10:10

I don\'t know if it\'s just too late or what, but I don\'t see how to do this...

What I\'m expecting to do, and what the object browser says is there, is this:

10条回答
  •  一整个雨季
    2020-12-25 10:27

    Extension method from this answer IList to ObservableCollection works pretty well

    public static ObservableCollection ToObservableCollection(this IEnumerable enumerable) {
      var col = new ObservableCollection();
      foreach ( var cur in enumerable ) {
        col.Add(cur);
      }
      return col;
    }
    

提交回复
热议问题