CollectionCap ICollection.SyncRoot

Mar 1, 2010 at 4:34 PM

Hello.

I have a question regarding the CollectionCap class. When I try to bind it to the ItemsSource Proeprty of an ItemsControl I get an NotSupportedException in the ICollection.SyncRoot implementation. 

Isn't it possible to implement that Property? I want to save my result as an IList and not as an IEnumerable (which I know that it would work). 

Thank you

Cheers,
Andreas

Coordinator
Mar 11, 2010 at 10:15 PM

Hi Andreas,

Thanks for the sugestion, locking via a SyncRoot may be possible to implement in obtics. There would be some consequences though. Locking your IList might freeze large parts of obtics because many things are interconnected.

I'd have to give it some thought.

Regs,

 

Thomas.

 

Apr 19, 2010 at 9:05 AM

Hi Thomas,

Can you imagine a workaround for the moment? This behaviour makes it impossible to bind a IList<T> to a ItemsControl, which I absolutely need to.

Thank you

Regs,

Andreas

 

Coordinator
Apr 20, 2010 at 5:59 PM

Hi Andreas,

The ObticsBindingHelper library contains a class ListReturnPath with an extension method ToListFactory. This method allows you to provide a custom implementation for the SyncRoot property. It would look something like:

YourObservableList.ToListFactory().SyncRoot((l,p) => null).Create();

This will create an IList whose SyncRoot property returns null.

Regards,

Thomas