View Issue Details

IDProjectCategoryView StatusLast Update
0001017NoesisGUIC# SDKpublic2022-03-31 20:31
ReporterZiriax Assigned Tosfernandez  
PriorityhighSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.3.0 
Target Version2.2.0Fixed in Version2.2.0b4 
Summary0001017: ItemsControl.ItemsSource not working with custom observable collection
DescriptionThe following C# collection does not work when assign to ItemsControl.ItemsSource

public class MyList<T> : IList, IList<T>, INotifyCollectionChanged

Removing INotifyCollectionChanged makes it work, but then you don't have change notification

The attached patch solves this, although I did not test the change notification yet

TagsNo tags attached.
PlatformAny

Relationships

related to 0002318 assignedsfernandez ItemsControl.ItemsSource not working with IEnumerable 

Activities

Ziriax

Ziriax

2017-02-15 12:05

reporter  

ExtendRegistry.inl.patch (689 bytes)   
Index: Src/Packages/Gui/CoreBindings/Src/ExtendRegistry.inl
===================================================================
--- Src/Packages/Gui/CoreBindings/Src/ExtendRegistry.inl	(revision 6258)
+++ Src/Packages/Gui/CoreBindings/Src/ExtendRegistry.inl	(working copy)
@@ -112,6 +112,8 @@
     {
         ExtendRegistry::AddInterface(type, Core::TypeOf<INotifyCollectionChanged>(),
             Core::CalculateParentOffset<ProxyExtendObservableList, INotifyCollectionChanged>());
+        ExtendRegistry::AddInterface(type, Core::TypeOf<IList>(),
+            Core::CalculateParentOffset<ProxyExtendObservableList, IList>());
     }
 
     typedef ProxyExtendObservableList Type;
ExtendRegistry.inl.patch (689 bytes)   
sfernandez

sfernandez

2017-02-21 13:23

manager   ~0004449

We'll fix it in a future release.

I think we need to have the 3 possibilities (an IList proxy, an INotifyCollectionChanged proxy, and an IList+INotifyCollectionChanged proxy) to provide the correct solution.
Ziriax

Ziriax

2017-02-21 13:28

reporter   ~0004452

Ok.

Now if I look at the current code in NoesisExtend.cs

            else if (typeof(System.Collections.IList).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()))
            {
                if (typeof(System.Collections.Specialized.INotifyCollectionChanged).GetTypeInfo().IsAssignableFrom(type.GetTypeInfo()))
                {
                    nativeType = Noesis.ExtendObservableList.Extend(TypeFullName(type));
                }
                else
                {
                    nativeType = Noesis.ExtendList.Extend(TypeFullName(type));
                }
            }

then it seems that only those types implementing both IList and INotifyCollectionChanged will be registered as ExtendObservableList.

So currently we can assume that whenever ExtendObservableList is used, the managed collection will implement IList and INotifyCollectionChanged.

So I guess my patch would be sufficient for the current code base.
jsantos

jsantos

2017-02-21 20:33

manager   ~0004469

Thanks for the patch! Sergio is going to study the integration soon.

Anyway, I wonder if there is a better way to expose C# interfaces in C++, the current approach seems to be very hardcoded and limited...

Issue History

Date Modified Username Field Change
2017-02-15 12:05 Ziriax New Issue
2017-02-15 12:05 Ziriax File Added: ExtendRegistry.inl.patch
2017-02-21 13:23 sfernandez Note Added: 0004449
2017-02-21 13:23 sfernandez Assigned To => sfernandez
2017-02-21 13:23 sfernandez Status new => assigned
2017-02-21 13:28 Ziriax Note Added: 0004452
2017-02-21 20:33 jsantos Note Added: 0004469
2018-11-01 02:14 jsantos View Status public => private
2018-11-22 20:06 sfernandez Target Version => 2.2.0
2018-11-22 20:06 sfernandez View Status private => public
2018-11-22 20:06 sfernandez Platform => Any
2018-11-26 19:25 sfernandez Status assigned => resolved
2018-11-26 19:25 sfernandez Resolution open => fixed
2018-11-26 19:25 sfernandez Fixed in Version => 2.2.0b4
2022-03-31 20:31 aberro Relationship added related to 0002318