This project has moved and is read-only. For the latest updates, please go here.


Jul 30, 2011 at 11:24 PM
Edited Jul 30, 2011 at 11:25 PM

How do you force the property grid to update?  For example, if I have my Car object loaded into the property grid, and the tank level goes from 100 to 98, I'd like to be able to refresh the property grid.  Right now, I'm unloading the car (by setting the watched object = null) and then loading it back up.  But that causes a lot of visual flashing.  Thanks and this work is awesome!

Jul 31, 2011 at 3:42 AM

As long as your object implements the INotifyPropertyChanged interface, if a value changes in code the PropertyGrid will reflect those changes automatically.

    public class Data : INotifyPropertyChanged
        private string _name;
        public string Name
            get { return _name; }
                _name = value;

        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string propertyName)
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
Jul 31, 2011 at 3:48 AM

Ah, I see.  Unfortunately, I don't have access to the source code of the target objects (in this case, XNA's 3D Model class).  Is there a way to manually goose the control, say once every 5 seconds to force a refresh?  (I'd just write a wrapper class around the target objects and add INotifyPropertyChanged, but there are potentialy hundreds of properties that I have to bolt it onto.)

Jul 31, 2011 at 4:17 AM

I just added an Update() method.  This method will force all property values in the PropertyGrid to be refreshed with the data from the SelectedObject.  Please download the latest source code and compile the solution int he Main folder.  Let me know if this solves your issue.

Jul 31, 2011 at 4:46 PM

You rock! Will report back with results.