SetProperty<P>(PropertyInfo<P> propertyInfo, P newValue) does not use INotifyPropertyChanged?

SetProperty<P>(PropertyInfo<P> propertyInfo, P newValue) does not use INotifyPropertyChanged?

Old forum URL: forums.lhotka.net/forums/t/4951.aspx


Goblin posted on Monday, June 09, 2008

I have a few issues with databinding when using CSLA's SetProperty function.
My business object looks a bit like this (class is called Account):
...
        private static PropertyInfo<string> NumberProperty =
            RegisterProperty<string>(typeof(Account), new PropertyInfo<string>("Number"));
        public virtual string Number
        {
            get { return GetProperty<string>(NumberProperty); }
            set { SetProperty<string>(NumberProperty, value); }
        }
...

I tried going through CSLA to find out where it leads:

SetProperty<P>(PropertyInfo<P> propertyInfo, P newValue) =>

SetProperty<P>(propertyInfo, newValue, Security.NoAccessBehavior.ThrowException) =>

LoadPropertyValue<P>(propertyInfo, oldValue, newValue, true) ??

As far as I can see, LoadProperty does not fire the PropertyChanging /PropertyChanged events. According to my tests, it does indeed break databinding as the display does not update when properties change 'behind the scenes'.

Is there something I'm missing?

RockfordLhotka replied on Monday, June 09, 2008

LoadProperty calls OnPropertyChanging() and PropertyHasChanged() (which calls OnPropertyChanged()). I just double-checked the code, and each FieldManager.SetFieldData() call is wrapped by the event calls.

Goblin replied on Tuesday, June 10, 2008

Okay - thanks for the check.

Must be something I'm doing wrong in my databinding in WPF then.

I have a list of readonly objects - then on SelectionChanged I set the ObjectDataProvider's ObjectInstance property to an editable version of the readonly object selected, but the display does not update.

Well, back to the drawingboard Smile [:)]

Goblin replied on Tuesday, June 10, 2008

Turns out it was timing, that was my enemy. I use the Infragistics Grid-control with a new object in and had a button to commit my object.

Turns out that in WPF, the button's click-event happens before the Infragistics RowLeave-event happens, so my changes didn't take effect before _after_ the commit had failed, so the object was not valid - and therefore not exchanged with a new object... I solved the problem by changeing the EditMode of the Grid to happen everytime the cells are updated.

Everything fired as it should - just in the wrong order (for me). Embarrassed [:$] Sorry for wasting your time Rocky.


Copyright (c) Marimer LLC