diff --git a/Maui.DataGrid/Extensions/ReflectionExtensions.cs b/Maui.DataGrid/Extensions/ReflectionExtensions.cs index 3582768..6206da9 100644 --- a/Maui.DataGrid/Extensions/ReflectionExtensions.cs +++ b/Maui.DataGrid/Extensions/ReflectionExtensions.cs @@ -45,7 +45,13 @@ internal static class ReflectionExtensions private static object? GetPropertyValue(object obj, string propertyName) { - var properties = PropertyTypeCache.GetOrAdd(obj.GetType(), _ => TypeDescriptor.GetProperties(obj)); + var type = obj.GetType(); + + if (!PropertyTypeCache.TryGetValue(type, out var properties)) + { + properties = TypeDescriptor.GetProperties(obj); + PropertyTypeCache[type] = properties; + } var propertyDescriptor = properties.Find(propertyName, false);