0

In my WPF application the user is inputting a GPS coordinates in the format of Degrees : Minutes : Seconds as decimal fraction of minutes.

So 60° 30' 45" would be entered as 60° 30.750' .

I then store it as a pure decimal number so the above example would be stored as 60.5125.

The idea was that so the users wouldn't mess up the input it would be set in 3 different textboxes. One for Degrees, other for Minutes and one for the fractionalSeconds. It's somewhat bad that one of the numbers is seperated into two textboxes but if they have to type the whole number in the are afraid of all the point or comma confusion and that they could mess up.

So one thing I thought might work was a IMultiValueConverter but it seems to only work with MultiBindings which is something I'm not doing here.

Currently my solution is to bind to different properties and do all the calculations in code behind but I'm not really happy about the fractional bit. I assume 3 fractional letters but if they enter only 7 and assume 0.700 but get 0.007 so I thought I would have to do a string format bit.

Is there a better solution out there. Can I use MultiValueConverter for something like this?

Ingó Vals
  • 4,788
  • 14
  • 65
  • 113
  • I'd recommend sticking to one text box and let the program parse the value _intelligently_ without restricting the user to one format only. Search for `'` and `"` proceed accordingly. (You can accept the space character in place of `°`) – John Alexiou Apr 11 '12 at 17:37
  • @ja72 I had already implmented it with two Textboxes but they want to be guided completely. If they are not sure how to do something they won't do it at all. – Ingó Vals Apr 11 '12 at 17:57
  • @Ingo: There are other ways to guide users. For example, a watermark in the text box with an example of expected input, or by popping up a mini guide when focus is on the text box. Or perhaps even auto-completion of some nature. Point is, it may be that your users are asking for the solution that they *think* best solves their problem. It would be prudent to understand the problem fully as their may be a far more effective manner of solving it. – Kent Boogaart Apr 11 '12 at 19:41
  • @KentBoogaart I suggested several things like a tooltip and such but was asked to do it this way. I was just wondering if that solution could be made easily so I could showcase the differences. – Ingó Vals Apr 12 '12 at 09:30

2 Answers2

2

You could try using a MaskedTextBox, such as the one from the Extended WPF Toolkit.

Phil
  • 42,255
  • 9
  • 100
  • 100
1

You could use a Masked TextBox. This implementation uses MaskedTextProvider which is a .net class.

LPL
  • 16,827
  • 6
  • 51
  • 95