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

Edited 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.
Comments: ** Comment from web user: BoucherS **

Hi,

This issue will be fixed in v2.5. The following type of properties will be managed and won't result in a lost of data :
-List<int>, List<double>...
-DoubleCollection
-int[], double[]...


Viewing all articles
Browse latest Browse all 4964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>