Aug 3, 2011 at 8:08 AM
Edited Aug 3, 2011 at 8:11 AM
I have an application where I use a Property grid. I have a list of string that i need to display in a
combo box. (Actually i have a set of parameters and I want to show these parameters' name in the ComboBox). I have seen many examples in the discussion area which gave me few idea but could not solve my problem completely. I am using a WPF
window where I keep the Property chart.
Main issue I am facing is that despite I define a 'TypeConverter' called 'StringCollectionConverter' and decorating the property with the this 'TypeConverter' as an attribute, during execution control is not reaching at the 'ConvertTo' I have
in the 'StringCollectionConverter' class.
And it result in displaying the the propert grid as a text box with text 'Visualizers.ModelView.StringCollection' where I am expecting the result to be a combo box
with few text in it.
Can any one please tell me what went wrong?
My code is given below.
My Propert class:
public class MyChartProperties : INotifyPropertyChanged
names = new StringCollection();
public StringCollection AvailableParams
this.names = value;
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
if (this.PropertyChanged != null)
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
My Converter class :
public class StringCollectionConverter : TypeConverter
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
if (destType == typeof(string) && value is StringCollection)
// Return department and department role separated by comma.
return base.ConvertTo(context, culture, value, destType);
Property Grid Xaml :
Title="PropertyGrid" Height="300" Width="300">
<DockPanel VerticalAlignment="Stretch" >
<wpg:PropertyGrid Name="wpg" DockPanel.Dock="Top" VerticalAlignment="Stretch" IsEnabled="True" ShowDescription="True">
public void SetInstance(Object obj)
this.wpg.Instance = obj;
In few samples I have seen samples where we have to mention the 'DataTemplate' But I don't have idea how to apply this in my given xaml. Sorry, i dont have much experience in WPF; I am new to this technology.
Link I have referred: http://wpg.codeplex.com/discussions/209860
Thanks in advance.