This project has moved. For the latest updates, please go here.

PropertyGrid Value Bind Problem

Oct 6, 2012 at 10:26 AM
Edited Oct 6, 2012 at 11:55 AM

Pretty simple propertygrid bound to an item (works fine); 

<xctk:PropertyGrid  SelectedObject="{Binding Path=SelectedObject}" ...

and the DataModel I set it to has some integer properties;

[Category("Log")]
[DisplayName("Track Columns")]
[Description("Number of Columns in the Log View")]
public int TrackColumns
{
    get
    {
        return ViewModel.TrackColumns;
    }
    set
    {
        ViewModel.TrackColumns = value;
        NotifyPropertyChanged("TrackColumns");
    }
}

The problem is that the default editor in the PropertyGrid doesn't behave properly. Firstly there is no where that I can see to change when it updates the value; I want it to bind with immediate effect - change the valid in any way and it sets the DataModel Property. So if you type a number and press enter, it doesn't update the value either at the moment. Secondly, If you press the "up" or "down" button once, it updates the value, press it twice or more and it stops updating the value until you press the opposite button, etc... 

Any work around?

 

 

Oct 9, 2012 at 3:51 PM

You could try to create your own CustomEditor thru the PropertyGrid.EditorDefinitions

Set the TargeType to "Int32" and use an IntegerUpDown in the DataTemplate.

When adding the binding, specify "PropertyChanged" as update source trigger (e.g. {Binding Value, UpdateSourceTrigger=PropertyChanged})