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 · 1 comment
Open

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

daihung opened this issue Jan 22, 2024 · 1 comment

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

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