"Model" property grid is not updated with new property value

Oct 25, 2012 at 7:43 PM
Edited Oct 26, 2012 at 6:20 AM

Hi,

A small problem. In my application, moving a shape (with a SelectionTool) can result in change of this shape's model. More exactly - one of the properties of the model object can change in certain situations. Imagine this change happens when the "Model" tab is active, and so the model's property grid displays model object of the shape being moved. Imagine you've moved a shape (and so the model's property changed). Well, you will not see the new property value in the property grid (although you should!) until you click on this property name (in the property grid) or switch from "Model" tab to "Shape"  tab and then switch back... and maybe other mysterious actions may help as well :)

Can you suggest any solution?

[UPDATE] Just for the case: (1) Model's property setter does have the OnPropertyChanged call, and (2) there are no property mappings between this model's property and some shape's property (in my application I do not use mappings at all - I simply do not need them).

Coordinator
Oct 26, 2012 at 7:46 AM

The standard PropertyGrid component does not automatically refresh property changes (because there is no interface for being notified when a property setter is called). The NShape PropertyController/-Presenter components use the IRepository events for firing ObjectChanged events that finally lead to an event handler calling PropertyGrid.Refresh().

Do you call Repository.Update(myModelObject) after changing the property? If yes, the PropertyGrid should be refreshed. If not, call the Refresh() method of the PropertyGrid manually.

Oct 26, 2012 at 8:15 AM
KurtHolzinger wrote:

Do you call Repository.Update(myModelObject) after changing the property? If yes, the PropertyGrid should be refreshed. If not, call the Refresh() method of the PropertyGrid manually.

No, I'm not calling the Repository.Update() method. So I'll try it. Thank You!

PS: Can't call PropertyGrid.Refresh because I do not have access to the PropertyGrid: model is changed in my custom SelectionTool, not in the form where PropertyGrid lives.