C
C#11mo ago
Poller

❔ Custom ObservableCollection behaves differently on WPF

As in the image shown this is my error message. The Collection i built, and use is found here: https://github.com/bPoller2810/MvvMHelpers/blob/main/MvvMHelpers.core/ConditionalObservableCollection.cs This Collection works without any issues in Xamarin.Forms, Maui and other non Framework useage. But in Wpf the error seen shows up. (every time). I Then created a mvp to recreate the error, but there it works. Sadly i could not find out : - Why does it talk about add, if i send "new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, index)" - Why does it fail anyway? (My Collection contains 1 element and my action is to type a letter that will get the element removed. this single removed element is on index 0) - (Bonus) Why does it not fail in the mvp. does anybody have an idea or deeper knownledge in wpf and can help me here?
15 Replies
SinFluxx
SinFluxx11mo ago
When is it actually erroring (do you have that relevant code)?
Poller
Poller11mo ago
Sure, here is the full code. The SearchTerm Property is bound to a TextBox. From The CollectionChanged Invoke on, its internal to wpf and i am not yet figured out stuff there
Poller
Poller11mo ago
Index resolved to 0 and internal items only contains 1 element. (my demo code uses strings instead of a model)
SinFluxx
SinFluxx11mo ago
You said it was referencing your Add as well?
Poller
Poller11mo ago
no. the error text says add.. wich is confusing as hell the Stacktrace shows "Add" is not involved. sorry for my confusing phrasing
SinFluxx
SinFluxx11mo ago
Ah yes just translated it, which sounds right as an added item wouldn't be at index 0, it would be at the end of the collection
Poller
Poller11mo ago
yeah. that error is confusing, because it happens in a Remove action.
SinFluxx
SinFluxx11mo ago
Just out of interest have you got the code for your RaiseCollectionAdd method? And the end of the line for RaiseCollectionRemove that's cut off?
Poller
Poller11mo ago
se thi initial post there is the full source of the collection(link) the index is not yet pushed that was my first solving attempt https://github.com/dotnet/wpf/blob/562aa8c8d86153ad89b4dd98c9f73a822072e637/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/EnumerableCollectionView.cs#L431 this seems my error
Accord
Accord11mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Poller
Poller11mo ago
24 Hours is pretty strict for stale. #server-feedback
Accord
Accord11mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Mayor McCheese
Mayor McCheese11mo ago
$close
MODiX
MODiX11mo ago
Use the /close command to mark a forum thread as answered
Accord
Accord11mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server
More Posts