Well, that's one way to do it
-
public ObservableCollection<MyType> MyTypeObservableList { get { var result = new ObservableCollection<MyType>(); foreach (var myType in _myTypeList) { result.Add(myType ); } return new ObservableCollection<MyType>(result); } }
[mod - edited to put code into a backtick fence to render better, after being flagged - PJH]
So it's creating an observable collection, adding everything in the list to it, then returning a new observable collection created with the observable collection he just created as the parameter.
-
That's a very reasonable way to do it... if you're doing lazy initialization. But there doesn't seem to be any initialization and saving of the value here, so...
-
@campkev said in Well, that's one way to do it:
adding everything in the list to it
One by one!
Yeah, there isn't a single thing here being done right...