Click here to Skip to main content
15,886,362 members
Home / Discussions / WPF
   

WPF

 
Questionscrollbar [modified] Pin
arkiboys30-Mar-11 22:03
arkiboys30-Mar-11 22:03 
AnswerRe: scrollbar Pin
Pete O'Hanlon30-Mar-11 22:28
mvePete O'Hanlon30-Mar-11 22:28 
GeneralRe: scrollbar Pin
arkiboys30-Mar-11 22:48
arkiboys30-Mar-11 22:48 
GeneralRe: scrollbar Pin
Pete O'Hanlon30-Mar-11 23:04
mvePete O'Hanlon30-Mar-11 23:04 
QuestionNavigating to a specific Panorama item Pin
Paul Harsent30-Mar-11 12:24
Paul Harsent30-Mar-11 12:24 
QuestionTelerik RadRadioButton Hover Effect Pin
Kevin Marois30-Mar-11 11:29
professionalKevin Marois30-Mar-11 11:29 
AnswerRe: Telerik RadRadioButton Hover Effect Pin
SledgeHammer0130-Mar-11 11:42
SledgeHammer0130-Mar-11 11:42 
QuestionWPF Entering Currency Pin
_Maxxx_30-Mar-11 2:10
professional_Maxxx_30-Mar-11 2:10 
OK - and I though this one was going to be easy!

I want a text box in a WPF form into which the user can enter a currency amount (e.g. $12.34)

I want to be able to give them an error message if they type in rubbish (e.g. "freds cash")

I want to be able to validate for ranges (so they can't for example, enter -ve numbers )

My 1st thought was to bind a standard textbox to my data property, which is a Decimal?, which doesn't work very well, as if the user types rubbish, an exception is thrown which (as far as I can ascertain) I can't catch!) I know I can display an error message/highlight the control if this happens, but this means that what is shown on the screen doesn't match what is in the property that I'm binding to - so what happens if the user now clicks the SAVE button? it saves the 'old' value, not what's on the screen, that's what!

Solutions I have seen include only binding to strings, and then validating the user input in the setter of those strings. Josh Smith does this here[^] While I like this idea, I feel a little uncomfortable - I'd really like to bind to the 'real' data and not a string representation of it.

Other solutions I came across included karl's solution here[^] which looks very interesting.

But I figure, WPF has been around for a while, so surely there's some accepted way of entering monetary amounts?

Am I missing something really obvious, so obvious that nobody's blogging about it? Or, am I just crap at Googling? Or, do I need to look at Josh or Karl's solution and use one of them? Or, is there a better way?
MVVM# - See how I did MVVM my way
___________________________________________

.\\axxx
(That's an 'M')

AnswerRe: WPF Entering Currency Pin
Pete O'Hanlon30-Mar-11 2:26
mvePete O'Hanlon30-Mar-11 2:26 
AnswerRe: WPF Entering Currency [modified] Pin
Pete O'Hanlon30-Mar-11 8:54
mvePete O'Hanlon30-Mar-11 8:54 
GeneralRe: WPF Entering Currency Pin
_Maxxx_30-Mar-11 12:42
professional_Maxxx_30-Mar-11 12:42 
GeneralRe: WPF Entering Currency Pin
Pete O'Hanlon30-Mar-11 13:01
mvePete O'Hanlon30-Mar-11 13:01 
QuestionBinding a Checkbox Column with a Byte Value 0 or 1 [modified] Pin
Vimalsoft(Pty) Ltd29-Mar-11 22:12
professionalVimalsoft(Pty) Ltd29-Mar-11 22:12 
AnswerRe: Binding a Checkbox Column with a Byte Value 0 or 1 Pin
Pete O'Hanlon29-Mar-11 22:52
mvePete O'Hanlon29-Mar-11 22:52 
GeneralRe: Binding a Checkbox Column with a Byte Value 0 or 1 Pin
Vimalsoft(Pty) Ltd30-Mar-11 2:27
professionalVimalsoft(Pty) Ltd30-Mar-11 2:27 
GeneralRe: Binding a Checkbox Column with a Byte Value 0 or 1 Pin
Pete O'Hanlon30-Mar-11 2:30
mvePete O'Hanlon30-Mar-11 2:30 
Questionproblem with cross-domain silverlight and WCF Pin
Yanshof29-Mar-11 5:11
Yanshof29-Mar-11 5:11 
AnswerRe: problem with cross-domain silverlight and WCF Pin
Pete O'Hanlon29-Mar-11 7:03
mvePete O'Hanlon29-Mar-11 7:03 
GeneralRe: problem with cross-domain silverlight and WCF Pin
Yanshof29-Mar-11 21:49
Yanshof29-Mar-11 21:49 
GeneralRe: problem with cross-domain silverlight and WCF Pin
Pete O'Hanlon29-Mar-11 22:25
mvePete O'Hanlon29-Mar-11 22:25 
GeneralRe: problem with cross-domain silverlight and WCF Pin
Yanshof29-Mar-11 23:23
Yanshof29-Mar-11 23:23 
GeneralRe: problem with cross-domain silverlight and WCF Pin
Pete O'Hanlon29-Mar-11 23:33
mvePete O'Hanlon29-Mar-11 23:33 
Questionusercontrol - silverlight 4.0 Pin
arkiboys29-Mar-11 5:04
arkiboys29-Mar-11 5:04 
AnswerRe: usercontrol - silverlight 4.0 Pin
Yanshof29-Mar-11 5:15
Yanshof29-Mar-11 5:15 
AnswerRe: usercontrol - silverlight 4.0 Pin
Mycroft Holmes29-Mar-11 13:04
professionalMycroft Holmes29-Mar-11 13:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.