hi all,
Can any one help me out in caluclating field value(sum) using the values of other two fields (if i have three columns in the xamDatagrid and all the fields are of type int) in the XAML code?
Thanks
Prakash
Hi Alex,
Thank you .
I think we have to use MutliBinding.Converter Property on the field but i am not sure how to use it on the xamdatagrid field.
Alex
Hello Prakash,
This concept sounds good but I am not sure if that is possible. I will try this and will post a follow-up if I succeed.
Alex.
Thanks for the reply. I did the same as you have explained and everything works fine.
But i have question :
Can i write a converter class which implements iMultiValueConverter interface and assign that class to the converter property of the xamdatagrid field?
If that is the case, you can use the following.
As you have set, column A and column B are integer. You can add an unbound field ( the sum field ) and handle the record updated event of the grid like following
e.Record.Cells["Sum"].Value represents the value of my unbound field.
private void xamDataGrid1_RecordUpdated(object sender, Infragistics.Windows.DataPresenter.Events.RecordUpdatedEventArgs e) { e.Record.Cells["Sum"].Value = (int)e.Record.Cells[0].Value + (int)e.Record.Cells[1].Value; }
If you want the unbound field to be initialized when the application starts, you can do that in the FieldLaytoutInitialized event like this;
private void xamDataGrid1_FieldLayoutInitialized(object sender, Infragistics.Windows.DataPresenter.Events.FieldLayoutInitializedEventArgs e) { foreach (DataRecord r in xamDataGrid1.Records) { r.Cells["Sum"].Value = (int)r.Cells[0].Value + (int)r.Cells[1].Value; } }
Hope this helps.
So that I understand you correctly, you want to display the sum of two cells in for each row?
FIeld A | Field B | SUM A+B
5 | 10 | 15
Regards,