I have a textbox in WPF and I would like to dynamically show the currency symbol, i.e. when the user edits the textbox and the textbox loses the focus, the currency symbol is automatically inserted at the end (beginning). I prefer it in XAML rather than hard-coding. I would like to mention that my textbox is not binded to anything.
this is the easiest approach
<TextBox Text="{Binding Value, StringFormat='$#,##0.0000;$(#,##0.0000)'}" />
value is your double or decimal money but you said it's "not binded to anything" i can't see how is that possible but you can do it by code if you want like so
value.ToString("$#,##0.0000;$(#,##0.0000)");
Look at the Masked TextBox that is part of the Extended WPF ToolKit. Or Google WPF Masked TextBox for other options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With