Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Closed Issue: PropertyGrid: Collections of primitive types bug [21463]

$
0
0
Using the PropertyGrid control, if one of the properties is of type List<T> ou T[], where T is a primitve type, the user can enter the values he wants, but they get lost. I found a fix, at least for collections of type List<T>:

Change PrimitiveTypeCollectionEditor.cs, ResolveValueBinding() to:
{
var type = propertyItem.PropertyType;
Editor.ItemsSourceType = type;

if (type.BaseType == typeof(System.Array))
{
Editor.ItemType = type.GetElementType();
}
else // if (type.ContainsGenericParameters)
{
Editor.ItemType = type.GetGenericArguments()[0];
}

base.ResolveValueBinding( propertyItem );
}
}

Change PrimitiveTypeCollectionControl.cs, ComputeItemsSource() to:
{
if (ItemsSource == null)
{
string tt = Text;
ItemsSource = CreateItemsSource();
Text = tt;
}

return ItemsSource;
}

NB: This last change is necessary not to loose the value when the collection object needs to be created. Otherwise, the OnTextChanged event is called when the collection object gets created, and the desired content gets lost.

Viewing all articles
Browse latest Browse all 4964

Trending Articles