FeatureRequest: In PropertyGrid ability to pass or bind current object instance to the template


Usage scenario:
I have an object which have some properties and the I want to allow users to make selections in other properties based on what they selected other property.
For example:
In one property "filename" I select a CSV file and then as soon as user select the file name I want to populate comboxes for other properties "firstname", "lastname" with column names read from CSV file, which could be for example "fname", "lname".
So later user could select which columns maps to what property in my object.
May be it can be achieved some other way, but I thought if we can pass an object value to the template we could simple bind it to the property of the object, lets say called "columnnames", that has all column names read from csv file and bind it to ComboBox.
Closed Oct 4, 2011 at 7:39 PM by brianlagunas
BY the way, this will only work in the current source code. This will NOT work in the release version 1.5


brianlagunas wrote Oct 4, 2011 at 7:38 PM

This is already possible. Start by creating a colleciton that will represent you List of options. Then define an EditorDefinition for the Column property:
                        <ComboBox ItemsSource="{Binding Path to your Options ItemsSource}"
                                  SelectedValue="{Binding Value}" />
Then when your FileName property changes simply set the Options collection to the correct items:
    private string _fileName;
    public string FileName
        get { return _fileName; }
            _fileName = value;

    private void UpdateOptions(string fileName)
        Options = new List<string>() { "Item 1", "Item 2", "Item 3" };

    private List<string> _options;
    public List<string> Options
        get { return _options; }
            _options = value;
Of course, this will be slightly different depending on how you are using your Model and ViewModel. You may need to add an event handler to the PropertyChanged event of your Model (which implements the INotifyPropertyChanged interface) and check for the FileName property and load your options collection accordingly.

wrote Oct 4, 2011 at 7:39 PM

olegkap wrote Oct 4, 2011 at 8:18 PM


Yea, I am using current source code.


wrote Feb 22, 2013 at 2:58 AM

wrote May 16, 2013 at 1:40 PM