Issue in displaying List of String in Combo - Urgent

Aug 3, 2011 at 8:08 AM
Edited Aug 3, 2011 at 8:11 AM

Hi there,

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:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace antarys_v3.Visualizers.ModelView
    public class MyChartProperties : INotifyPropertyChanged
        StringCollection names;

        public MyChartProperties()
            names = new StringCollection();
        public StringCollection AvailableParams
                return this.names;
                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 "Something";
            return base.ConvertTo(context, culture, value, destType);

Property Grid Xaml :

<Window x:Class="MyTester.PropertyGrid"
    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:

Thanks in advance.