Friday 15 February 2013

.net - What strategy should be used for converting real world measurements to WPF units? -


We have an application that will have to read the real world dimensions from DB in the dematrators, presented the values ​​to the user then Currently in the WPF I will be using the following strategy when I am reading the following example by multiplying the object by MilimetresPrWpfUnit data accumulation.

  public cut double millimeterpirch = 25.4; Public Construction Double WpfUnitsPerInch = 96; Public Constance Double-Millimeters PerWpfUnit = WpfUnitsPerInch / MilimetresPerInch;  

While loading and creating objects, I am converting into objects, although this problem produces that when the user selects the object on the screen, then the size of that object Should be changed back to the real world size, it is not much of a problem, but a lot of conversions are going on.

Is there a utility in WPF to convert the unit size to a metric? This can be the best solution.

Optional is to create a IValueConverter which will be converted from / to metric units, although I'm afraid that there may be a performance effect.

A few ways to reach it ...

The IValueConverter method is definitely a way to deal with this, or you can write the method that changes the data into metrics When the data is being loaded, everything in it is actually a design-specific scenario and some where one will need to see more code or make more general details of the algorithm for making any appropriate recommendations. Pvt Would be appropriate.


No comments:

Post a Comment