C
C#16mo 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
SinFluxx16mo ago
When is it actually erroring (do you have that relevant code)?
Poller
PollerOP16mo 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
PollerOP16mo ago
Index resolved to 0 and internal items only contains 1 element. (my demo code uses strings instead of a model)
SinFluxx
SinFluxx16mo ago
You said it was referencing your Add as well?
Poller
PollerOP16mo 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
SinFluxx16mo 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
PollerOP16mo ago
yeah. that error is confusing, because it happens in a Remove action.
SinFluxx
SinFluxx16mo 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
PollerOP16mo 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
Accord16mo 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
PollerOP16mo ago
24 Hours is pretty strict for stale. #server-feedback
Accord
Accord16mo 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 McCheese16mo ago
$close
MODiX
MODiX16mo ago
Use the /close command to mark a forum thread as answered
Accord
Accord16mo 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