When I have a property with a custom type which has a type converter attribute, the property grid only shows the type name of the property, not the value provided by the type converter. Binding the same property to a TextBox lets me edit the proper converted type.
```
class Sample
{
public StringDictionary StringMapping
{
get
{
return _stringMapping;
}
set
{
if (_stringMapping == value)
return;
_stringMapping = value;
OnPropertyChanged();
}
}
}
[TypeConverter(typeof(StringDictionaryConverter))]
[Serializable]
public class StringDictionary : Dictionary<string, string>
{
public StringDictionary()
{
}
protected StringDictionary(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
public class StringDictionaryConverter : SimpleDictionaryConverter<string, string, StringDictionary>
{
// convert dict to "key1=value1 key2=value2 ..." and vice versa
}
```
A text box will let me edit the values, while the property grid only shows "somenamespace.StringDictionary"
Comments: ** Comment from web user: BoucherS **
```
class Sample
{
public StringDictionary StringMapping
{
get
{
return _stringMapping;
}
set
{
if (_stringMapping == value)
return;
_stringMapping = value;
OnPropertyChanged();
}
}
}
[TypeConverter(typeof(StringDictionaryConverter))]
[Serializable]
public class StringDictionary : Dictionary<string, string>
{
public StringDictionary()
{
}
protected StringDictionary(SerializationInfo info, StreamingContext context)
: base(info, context)
{
}
}
public class StringDictionaryConverter : SimpleDictionaryConverter<string, string, StringDictionary>
{
// convert dict to "key1=value1 key2=value2 ..." and vice versa
}
```
A text box will let me edit the values, while the property grid only shows "somenamespace.StringDictionary"
Comments: ** Comment from web user: BoucherS **
Hi,
You can override the ToString method on your object property to display what you want.
Please have a look at sample "Data/PropertyGrid/UsingSelectedObjects/Using Attributes", from the LiveExplorer App, available here : http://wpftoolkit.codeplex.com/.
You will see the override of the ToString method in the "Code" Tab of the sample.