-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add StringFormat dependency property to NumericUpDown and DecimalUpDown #3758
Comments
@jamesport079 Although not exactly what you're requesting, there are attached properties available that allow you to set a prefix/suffix text... So you could do something like this: <materialDesign:NumericUpDown Style="{StaticResource MaterialDesignFilledNumericUpDown}"
materialDesign:TextFieldAssist.PrefixText="$"
Value="100" /> Which would give you a control with a dollar sign prefixed before the actual value: And if you want decimals as well, using the |
Thank you! Didn't know about this. This partially solves my problem. Having said that I still think that having direct access to StringFormat in the text displayed is the way to go. With DecimalUpDown there is no way to format the number of decimal places for example. Also, different countries represent money differently which is nicely handled by StringFormat in WPF. |
No, you're missing a lot. First of all that is not the proper way how to represent currency in Euro. Second of all, the way Euro currency is represented varies from country to country within the same European Union. So in Italy it would be 40 Euros will be represented as "40,00 €" but in Ireland it will be "€ 40.00" ..... See the difference? Italy has the Euro sign after and uses comma and Ireland uses fullstop with the euro sign before. There are a lot of other nuisances when representing currency that I don't want to waste time to handle them myself when WPF and Windows itself does a nice job with StringFormat. You can read more about the how Euro is written in different countries in this article.... https://en.wikipedia.org/wiki/Language_and_the_euro |
This is harder to implement than I expected it to be. A few things I have noticed:
(Though this could be due to my implementation)
<TextBox Style="{x:Null}" Text="{Binding MyDecimal, StringFormat='{}{0:c}'}" /> (Note: this issue can be fixed as described here, but I think this is besides the point and not viable for this issue.) This is the branch I was testing/working with, but at this point I think it's easier to start fresh: |
Text in NumericUpDown should be able to be formatted to represent currency for example or to format the number of decimal places in DecimalUpDown.
Ideally a StringFormat gets added as a dependency property to these controls to be able to format the number accordingly.
The text was updated successfully, but these errors were encountered: