Hi,
I bind my XamDataGrid directly to an ObservableCollection of poco objects. There's a case where I need to publish an Event using EventAggregator in a property set, for example
public Decimal Amount
{
get { return amount; }
set { amountSetEvent.Publish(new AmountSetEventArgument(this, value); }
}
But I can't use the event aggregation in that POCO object. So I'm searching, if it's possible to have an OnPropertyChanging event triggered after the user updated the value and before the property is set, with access to the new value and the possibility to cancel the event so that the property is not set. Or any other suggestion are welcome.
Thanks,
Hello Dominik,
I have been looking through your issue and I suppose you want to make validation on your values. Since you use a XamDataGrid to display your data you can use ValueConstraint class in the Editors which are used in the grid to edit the data. Here you can read more about ValueConstraint class:
http://help.infragistics.com/NetAdvantage/WPF/2011.1/CLR4.0/?page=InfragisticsWPF4.Editors.v11.1~Infragistics.Windows.Editors.ValueConstraint_members.html
and here you can read more about InvalidValueBeahvior property and how to use ValueConstraint:
http://help.infragistics.com/NetAdvantage/WPF/2011.1/CLR4.0/?page=InfragisticsWPF4.Editors.v11.1~Infragistics.Windows.Editors.ValueEditor~InvalidValueBehavior.html
Please let me know if this is what you are trying to achieve or you need further assistance on this matter.
Looking forward for your reply.
Hi Stefan,
Thank for the answer, the ValueContraint will be useful else where in my project. Sorry I haven't been explicit. What I'm trying to achieve is to pop up a dialog to properly edit the field (the dialog validate but also allow the user to add comment about why he modify this fields and there's also other options). The use case is,
1. The user click on the field to edit the field.
2. The user edit the field.
3. Upon field lost focus, the pop up dialog (using prism event aggregator) open containing the value the user just entered. (Notice that the model haven't been updated)
4. The user complete the dialog,
4.1. by clicking the 'OK' button the user commit change to the model (client side),
4.2. by clicking the 'Cancel' button the user discard the change.
Hello again,
I have been looking through your post and I created a sample project for you. Basically I add a window which I show on EditModeEnding event and based on the user’s choice ( Save or Cancel) I determine whether to set the value or not. I use a global variable for that purpose. Please let me know if you need any further clarifications on this matter.
Thank you for your feedback and I am glad I helped you. I believe other community users may benefit from this as well.
Thanks again.
Hello Stefan,
Oh yes, it work,
I appreciated your help.
Dominik
I am glad I helped you. Now looking through your post I can suggest you use the e.Editor.Value to get the new Value of the Cell and e.Cell.Value to get the old one. Please let me know if you need further assistance on this matter.
Thanks for your response, almost perfect, one small thing, I can't get the new value of the field in EditModeEndingEventArgs, I can see the old value but not the edited one.
For instance if the current value is 20 and the user click the cell, edit the value to 19, out focus, I need to popup the dialog containing the edited value '19' in a textbox.
Regards,