Hello,
I noticed a strange behavior when using the calculation manager and having more then one fields that are calculated that use input fields that are themself calculated: If the input fields are placed after the calculated field (later in the visual tree) then the calculation only works for the first calculated field. If the input fields are placed in front of the calculated fields then everything works fine.
I attached a solution that illustrates the issue. The BSA field is not calculated in the first example and you can see there are "Invalid reference" errors. The second example however works fine.
Do you have any Ideas what could be the issue here?
Hope to hear from you soonJohannes
Hello Johannes,
Thank you for your post. I have been looking into your issue and it seems that it occurs because you are setting the formula which contains objects before to be initialized. In your second scenario the editors that you refer in the formula are created before that and everything goes right. To achieve the desired behavior in the first scenario you can handle the ‘ValueChanged’ event of the editor with id “Weight” and put the formulas in its body like e.g. :
private void XamNumericEditor_ValueChanged(object sender, System.Windows.RoutedPropertyChangedEventArgs<object> e)
{
ControlCalculationSettings calcSettings1 = new ControlCalculationSettings();
calcSettings1.Formula = "0.007184 * power([//Height], 0.725) * power([//Weight], 0.425)";
XamCalculationManager.SetControlSettings(xneResult2, calcSettings1);
XamCalculationManager.SetCalculationManager(xneResult2, CalculationManager);
ControlCalculationSettings calcSettings2 = new ControlCalculationSettings();
calcSettings2.Formula = "10000 * [//Weight] / [//Height] / [//Height]";
XamCalculationManager.SetControlSettings(xneResult1, calcSettings2);
XamCalculationManager.SetCalculationManager(xneResult1, CalculationManager);
}
Let me know, if you need any further assistance on this matter.
Hi Yanko,
thanks for the reply. Well, this does not help me much. This was just an example. Our forms are created dynamically, there is no way of telling where a field is put on the form. And also: if I remove the BMI field, the BSA field will be calculated. Why is it possible to calculated one field but not the other?
RegardsJohannes
Hello Johanna,
I have logged this behavior with our developers in our tracking system, with an issue ID of 134251. Peter has created a support ticket on your behalf with number CAS-111274-Y9V6M7 in order to link the development issue to it so that you are automatically updated when a Service Release containing your fix is available for download.
I've done some more digging. I think I found a workaround: If I am not mistaken the default CalculationFrequency is set to Asynchronous. If you set it to Synchronously then the calculation seams to work correctly.
Can you confirm that there are no sideeffects by synchronously calling the calculations?
We have shipped out a new service release where your issue is resolved. I'd be glad to find out if you had tested it out and if it had met your requirements.
You can download the Service Releases by logging to our web site and going to Account \My Keys and Downloads.