HateDread
Topic Author
Posts: 72
Joined: 06 Feb 2020, 10:27

How to copy ObservableCollection?

07 Jan 2024, 12:26

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.
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: How to copy ObservableCollection?

09 Jan 2024, 12:28

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.

Who is online

Users browsing this forum: No registered users and 5 guests