Hi,
There is a bug in the propertyGrid of 2 dimensions arrays : https://wpftoolkit.codeplex.com/workitem/21501.
It should be fixed in v2.5.
Once fixed you could use EditorTemplateDefinition with a Converter :
There is a bug in the propertyGrid of 2 dimensions arrays : https://wpftoolkit.codeplex.com/workitem/21501.
It should be fixed in v2.5.
Once fixed you could use EditorTemplateDefinition with a Converter :
<xctk:PropertyGrid.EditorDefinitions>
<xctk:EditorTemplateDefinition TargetProperties="MyArray">
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<TextBlock Background="Yellow"
Text="{Binding Value, Converter={StaticResource ArrayConverter}}" />
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
</xctk:PropertyGrid.EditorDefinitions>
public class ArrayConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
{
string returnString = "";
var array = value as double[ , ];
for( int i = 0; i < array.Length / 2; i++)
{
returnString += "(" + array[i,0] + ", " + array[i,1] + ")";
}
return returnString;
}
public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
{
throw new NotImplementedException();
}
}
or a CustomEditor : [Editor( typeof( ArrayEditor ), typeof( ArrayEditor ) )]
public double[ , ] MyArray
{
get;
set;
}
public class ArrayEditor : Xceed.Wpf.Toolkit.PropertyGrid.Editors.ITypeEditor
{
public FrameworkElement ResolveEditor( Xceed.Wpf.Toolkit.PropertyGrid.PropertyItem propertyItem )
{
var array = propertyItem.Value as double[ , ];
var list = new List<string>();
for( int i = 0 ; i < array.Length / 2; i++ )
{
list.Add( "(" + array[ i, 0 ] + ", " + array[ i, 1 ] + ")" );
}
ComboBox comboBox = new ComboBox();
comboBox.ItemsSource = list;
comboBox.SelectedIndex = 0;
return comboBox;
}
}