I am dynamically generating a fieldlayout in code behind so that I can achieve a column per month over a variable span of months. I am providing a binding expression for these dynamically generated fields like: ForecastedCosts[MonthYear].Cost.
When evaluated, the first part of the binding expression (ForecastedCosts[MonthYear]) may resolve to be a "proxy" object or a "real" object. The general idea is that transient proxy objects are used for cells that don't have real persisted data but still need to be rendered in the UI. When the proxy object is edited, the owning collection "swaps" it out for a "real" object. This mechanism works fine although cells that utilize the following binding ForecastedCosts[MonthYear].Cost never let go of the reference to the proxy object originally at ForecastedCosts[MonthYear]. Subsequent edits to that cell are still being propagated to the proxy object instead of the "swapped" real object. INotifyPropertyChanged is being subscribed to on the proxy object because the owner of the Cost property is the proxy object when the binding is first set up.
Now, one solution to this is to change the model a bit so that the Cost Property formerly accessed through ForecastedCosts[MonthYear].Cost. can be accessed directly at ForecastedCosts[MonthYear], but I need to get access to other properties that are data-model wise peers of the Cost property.
Is there a way to tell a cell to completely re-evaluate its bindings?
Thanks.
Did this help? If not, then how is your proxy structured? If it contains the real object, then it can simply expose the contained object and pass through property changed events. This code is freehand, so I apologize for syntax.
interface IProxyInterface { string Name {get;set;} } class A : IProxyInterface, INotifyPropertyChanged { private string _name; public string Name { get { return _name; } set { _name = value; this.BaseRaisePropertyChanged(t => t.Name); } } } class B : IProxyInterface, INotifyPropertyChanged { private IProxyInterface _a; private IProxyInterface Contained { get { return _a; } set { _a = value; _a.PropertyChanged += (sender, e) => RaisePropertyChanged(e.PropertyName) }; RaisePropertyChanged<B>(t => t.Contained); } } public string Name { get {return _a.Name;} set { _a.Name = value; } } }
Hello,
I apologize that no one has yet answered this post. We were inundated with more posts than we had resources to cover. Since that time we have been adding people to the task of making sure every post gets a reply from an Infragistics employee.
If your data model or View model is using INotifyPropertyChanged, you can notify of any property changed for any property in your view. So one property can trigger a property notification on another by simply raising the PropertyChanged event in the class.
If you are using BindingList, there is a method you can call - ResetBindings(). This will force the BindingList to update itself from its coupled source.
You can read more about XamDataGrid binding scenarios in the following blog:http://blogs.infragistics.com/blogs/curtis_taylor/archive/2010/11/06/xamdatagrid-101-data-binding-basics.aspx
Sincerely,