We have an application that will be reading real world dimensions from the DB in milimetres, these values will then be presented to the user in WPF. Currently I'm using the following strategy when reading objects from the data store by multiplying MilimetresPrWpfUnit
in the following example.
public const double MilimetresPerInch = 25.4;
public const double WpfUnitsPerInch = 96;
public const double MilimetresPerWpfUnit
= WpfUnitsPerInch / MilimetresPerInch;
When loading and creating objects I'm currently converting as objects are being created, however this poses the problem that when the user selects an object on screen the size of that object needs to be converted back to the real world size, this isn't much of a problem but there is a lot of conversion going on.
Is there any utility in WPF to handle changing the unit size to metric? That might be the best solution.
The alternative is to create an IValueConverter
that will convert from/to metric units, though this I fear could have a performance impact.