This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi Ivan I was looking for the PropertyChanged Event and on reading the posts, it appears there is not one! This seems odd, as I can't imaging using the grid without one. Is this planned for a nightly build? (Since we are planning on using this to support editing of legacy objects, we need this feature to keep our data objects in sync. We will be using many built-in editors, many custom editors, and alowing our customers to plug their own editors in too. We wouldn't want to add the event to every editor, this should be handled by the grid itself) Thanks, -Paul |
|
|
Incidentally, I tried various spike solutions where the object being edited was a DependencyObject and the properties were DependencyProperties... but the only results I got involed getting Change events with every keystroke. The .Net propertygrid is more friendly, it seems to raise the event only when the edit field loses focus.
|
|
|
The reason we don't raise a PropertyChanged event is that we don't necessarily know when a value has changed. The data transfer between the grid and the edited object is handled by the data binding, i.e. by WPF behind the scenes. We can intercept this in certain scenarios but not always: therefore if the grid were to raise a PropertyChanged event it would not be reliable. In WPF it is usual for bound objects to implement INotifyPropertyChanged. This means that the change notifications come directly from the object itself: this is guaranteed to be reliable, and better still it is reliable even if other controls or code update the object -- raising of the notifications is centralised instead of you having to listen to multiple controls and/or gate programmatic access to the object. However if you are binding directly to legacy objects then implementing INotifyPropertyChanged may not be practical. If this is the case then could you let us know a bit more about your synchronisation needs and your design constraints, and we will see if we can come up with something. Regarding the frequency of change events, the grid's default text editor's data binding has an UpdateSourceTrigger of PropertyChanged. To have the data source updated only when an editor loses focus, create a custom editor whose Binding.UpdateSourceTrigger is LostFocus. However, one thing to watch out for in this case is that if the user performs an action which doesn't take focus away from the editor -- e.g. pressing Ctrl+S to save -- then the binding will not yet have updated the source, so the action will use the old value. |
|