This is a migrated thread and some comments may be shown as answers.

RadObservableCollection<T>.ShouldResetOnResumeNotifications

3 Answers 115 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Erhan
Top achievements
Rank 1
Erhan asked on 20 Oct 2016, 08:37 PM

how do we set RadObservableCollection<T>.ShouldResetOnResumeNotifications to false?

there is no public constructor that allows for this and the property is readonly ...

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 24 Oct 2016, 11:03 AM
Hi Erhan,

We had the pretty ambitious idea to implement an alternative mode that translates all reset actions to add/remove actions. However, is occurred that most of the WPF ItemsControls do not properly handle an Add/Remove action that contains more than one added/removed item. As RadObservableCollection<T> is widely used out of the scope of our controls, we had to freeze the work on this feature, due to those compatibility issues. Currently it is not possible to prevent Reset after ResumeNotifications.

Regards,
Ivan Ivanov
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
0
Michael Tissington
Top achievements
Rank 1
answered on 09 Aug 2020, 09:28 PM
Then I think the documentation should be corrected :)
0
Dinko | Tech Support Engineer
Telerik team
answered on 12 Aug 2020, 11:14 AM

Hi Michael,

Thank you for the provided feedback.

Upon checking, I can see that this property is described in the Properties section of this article.  We will consider adding a note in the section claiming that you can't Reset the collection after ResumeNotifications.

Regards,
Dinko
Progress Telerik

Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
commented on 09 Dec 2021, 02:28 PM | edited

Hi Dinko,

Sorry for necroing this but this is the only thread I could find by searching "ShouldResetOnResumeNotifications" in the forum.

I was curious too about the usage of this property.

I don't see clearly mentioned in the documentation that we can't reset the collection after ResumeNotifications.
After all, if this property is of no use, why do you even keep it exposed in the API?

I think keeping it only makes users lose time when they are looking for its usage, exactly like me right now.

In fact, I think the doc is clearly misinforming! It states:

"Calling the ResumeNotifications method after adding items to the collection with suspended notifications raises the CollectionChanged event with NotifyCollectionChangedAction.Reset."

From my understanding, this means Reset will actually be called after ResumeNotifications, but you state the contrary.

Even more confusing is that this property ShouldResetAfterResumeNotifications is false by default and we can't change it; so if it's false, why is Reset called anyway after ResumeNotifications()?

Thanks for your answer!

Martin Ivanov
Telerik team
commented on 10 Dec 2021, 09:29 AM

Indeed, the correct statement here is that calling the ResumeNotifications will always call CollectionChanged with Reset action.

Note that the ShouldResetAfterResumeNotifications property is True by default and there is no public API to change this. Here is how the property is initialized in the constructor of the RadObservableColleciton class.

public RadObservableCollection()
{
       this.ShouldResetOnResumeNotifications = true;
}

To summarize this, you can change the property only through a reflection. Its purpose is to determine if the notifications will be resumed with a single Reset action, or with multiple Add/Remove actions. Because of the nature of WPF there is not much sense to use this, but it was requested and introduced back in the days. Changing this could cause a breaking change that we prefer to avoid. Anyway, we are going to update the documentation with information about the property.

Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
commented on 10 Dec 2021, 10:49 AM

That's strange then, because when I was debugging I saw that the value of this "ShouldReset" was false. Can it change at runtime on your side?  Anyway, if it's not used for anything it doesn't really matter.

Thanks for the info!

Martin Ivanov
Telerik team
commented on 10 Dec 2021, 11:40 AM

The flag is used internally by the methods of RadObservableCollection, but its value cannot be changed (to false), unless using a reflection.
Tags
General Discussions
Asked by
Erhan
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Michael Tissington
Top achievements
Rank 1
Dinko | Tech Support Engineer
Telerik team
Share this question
or