Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PropertyGrid incorrect editor for IList of T, T is primitive type? #1767

Open
daihung opened this issue Jan 22, 2024 · 3 comments
Open

PropertyGrid incorrect editor for IList of T, T is primitive type? #1767

daihung opened this issue Jan 22, 2024 · 3 comments

Comments

@daihung
Copy link

daihung commented Jan 22, 2024

If I have these properties with item type is primitive type

public IList<int> IListOfInt { get; set; }
public List<int> ListOfInt { get; set; }

PropertyGrid is correctly return 'PrimitiveTypeCollectionEditor' as default editor for List<int>. However, for IList<int>, it returns 'CollectionEditor' as the default editor.

I will thought IList<int> should also use 'PrimitiveTypeCollectionEditor', why not?

@XceedBoucherS
Copy link
Collaborator

Hi,

Thank you for the request. You are right !
This will be fixed in the next release.
In the meantime, if you have the source code for Toolkit WPF, you can go in file
Xceed.Wpf.Toolkit/Core/Utilities/ListUtilities.cs
In method GetListItemType
and replace
var iListOfT = listType.GetInterfaces().FirstOrDefault(
( i ) => i.IsGenericType && i.GetGenericTypeDefinition() == typeof( IList<> ) );
with:
var iListOfT = ( listType.IsGenericType && ( listType.GetGenericTypeDefinition() == typeof( IList<> ) ) )
? listType
: listType.GetInterfaces().FirstOrDefault( ( i ) => i.IsGenericType && i.GetGenericTypeDefinition() == typeof( IList<> ) );

Thank you

@daihung
Copy link
Author

daihung commented Jul 29, 2024

Hi @XceedBoucherS,
Thanks for the fix on the new release.
While I'm testing it and noticed similar situation with IList<decimal> type, that it defaults with CollectionEditor and not able to make any modifications, is this an expected editor?

@XceedBoucherS
Copy link
Collaborator

Hi,

Based on Microsoft documentation, "decimal" type is not a Primitive type : https://learn.microsoft.com/en-us/dotnet/api/system.type.isprimitive?view=netframework-4.0

But we just made an exception to support the decimal type in IList and use the PrimitiveTypeCollectionEditor.
It will be part of the next release.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants