Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1750
Unit conversions in bound column
posted

Hello Community!

 

Following situation, I created a datagrid to display some settings (length, heigt, degrees) to the user. Our customer wants to be able, to show the current measurement units ([mm], [inch]). Depending if the unit is in [mm], the value should be shown with one decimal digit and the [mm] unit in the same column.
If the measurement system set to [inch] the value should be displayed with two decimal digits and [inch] in the same column.

 

As the values are later transfered to a plc, I have to do some conversions e.g. calculate the corresponding value of inch input to [10/mm] as the datatype in the bound list is an integer and is later transfered to a PLC.

I know that I should use an multivalue converter with two values. The first value (the input value) is bound to the current DataItem of the bound list. The second value for the converter is a property on the ViewModel.

Where do I have to add the MultivalueConverter and how should I add the binding to the ViewModel Property? Are there any examples or is there a better way for unit conversions?

Thank you for the input!