Page 1 of 1

Issue with ObservableCollection.Move

Posted: 02 Sep 2019, 10:25
by Jamieh
Using Noesis in Unity to rewrite/port an old Silverlight App. Most things are going great. However I've run into a problem.

I have an ObservableCollection<T> that is a dependency property of a custom control. This collection is being put into a ListView.

The initial binding is working find, and I'm getting the data. However, I'm attempting to sort the data using ObservableCollection.Move(), and when I do that I'm getting this error in Unity:

[noesis] Unimplemented
UnityEngine.Debug:LogError(Object)
NoesisUnity:UnityLog(Int32, String) (at Assets/NoesisGUI/Plugins/NoesisUnity.cs:116)
Noesis.Extend:Noesis_LaunchCollectionChangedEvent(IntPtr, IntPtr, Int32, IntPtr, IntPtr, Int32, Int32)
Noesis.Extend:NotifyCollectionChanged(Object, NotifyCollectionChangedEventArgs) (at Assets/NoesisGUI/Plugins/API/Core/Extend.cs:4359)
System.Collections.ObjectModel.ObservableCollection`1:Move(Int32, Int32)

Am I doing something here that Noesis doesn't support? Should I be sorting the ObservableCollection via a different method that .Move()? If I recreate the ObservableCollection I can get it to work, but then I lose the binding to the viewmodel that allows me to remove/add items.

I can post code if needed, however I'd like to get a sense of whether what I'm trying to do is supported or not. Or if someone has seen this specific error before and might know what I've done wrong. Thanks!

Re: Issue with ObservableCollection.Move

Posted: 03 Sep 2019, 02:28
by jsantos
This is not properly implemented. I am not sure how this was not reported before, could you please open a ticket about it?

Re: Issue with ObservableCollection.Move

Posted: 03 Sep 2019, 02:32
by jsantos
As a workaround, for now, you can use Sets to sort the collection. Sorry for the inconvenience.

Re: Issue with ObservableCollection.Move

Posted: 03 Sep 2019, 07:44
by Jamieh
Cool, I just wasn't sure if I was doing something wrong or unsupported.

I found a hack/workaround. It involves tracking the change notification of the ObservableCollection and rebinding ItemsSource anytime anything changes. Probably not great for perf, but it actually seems to work fine.

I will open a ticket. Thanks!

Re: Issue with ObservableCollection.Move

Posted: 04 Sep 2019, 23:51
by jsantos
Thanks for the ticket (#1550)