This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have been trying to used your product. The problem that I am having is that I would like for a user to type "2050" and after the "TextBox" is not focus the data would change to "$20.50". I have been looking for examples to do something like this but the only examples that I see has to do with using the "Spin". Please help. Thanks
|
|
|
Hmm, the problem is that we would interpret typing 2050 into a currency text box as meaning $2050 rather than $20.50. One possible solution to this would be to use an attached behaviour. On loss of focus, the attached behaviour would get the value of the currency text box, divide it by 100 and set the value of the currency text box to the new value. I haven't tested this idea but I believe it should work; if it doesn't, or if you would like us to work up a sample for you, let us know. |
|
|
Thanks for the quick responds Ivan. I did a few test and that seem to work.
|
|
|
Hi Ivan, How can I do a zero fill. If I only enter "$12.". How can I fill in "$12.00". Here's the code that I am currently using. <Label Height="28" HorizontalAlignment="Left" Margin="10,10,0,0" Name="label1" VerticalAlignment="Top" Width="120">Price Amount</Label>
|
|
|
Hmm, we should probably support that as an automatic feature. In the meantime, here is a solution but I am afraid it is a bit ugly. The idea is to handle the LostFocus event and in the event handler write: private void CurrencyTextBox_LostFocus(object sender, RoutedEventArgs e) The CurrencyTextBox formats the value (to the appropriate format for the specified culture, including zero padding) when the Value property is set, but only if the value is actually changing, hence the ugly +1/-1 dance. You can of course encapsulate this as an attached behaviour to avoid having to remember to specify LostFocus on every control, or derive a custom control from CurrencyTextBox and override any required focus handling methods: public class AutoFormattingCurrencyTextBox : CurrencyTextBox We will look at automating this behaviour so that the workaround is not necessary, but hopefully in the meantime this will be an acceptable workaround. |
|
|
Thanks Ivan, The code you gave me works great ! Thanks again for your quick respond.
|
|