Page 1 of 1

How to copy ObservableCollection?

Posted: 07 Jan 2024, 12:26
by HateDread
I have a function as so
Noesis::ObservableCollection<FleetNodeEntityViewModel>* GetChildren() const;
And want to copy those ptrs out to another collection so the collection itself can be modified without affecting the original collection. In C# it was the following
ChildrenToDisplay = new ObservableCollection<FleetNodeEntityViewModel>(selectedNode_.Children);
But I can't seem to get a copy step going in Noesis that isn't just pointing back at the same collection, and the copy constructor is deleted.

E.g.
Noesis::Ptr<Noesis::ObservableCollection<FleetNodeEntityViewModel>> childrenToDisplay_
// ...
childrenToDisplay_ = Noesis::MakePtr<Noesis::ObservableCollection<FleetNodeEntityViewModel>>(selectedNode_->GetChildren());
// or
childrenToDisplay_ = Noesis::Ptr<Noesis::ObservableCollection<FleetNodeEntityViewModel>>(selectedNode_->GetChildren());
// or
Any ideas?

Thanks.

Re: How to copy ObservableCollection?

Posted: 09 Jan 2024, 12:28
by sfernandez
Hi, there is no helper method to copy from other collection, could you please report that in our bugtracker?
In the meantime I've seen that C# is just adding each item individually from the source collection, so you can do something similar.