StringFormat in XAML, WPF : Currency Formatting

痴心易碎 提交于 2019-12-21 13:32:48

问题


How can i obtain currency formatting according to my country i.e indian rupee, INR or Rs ??

Please tell me the way to achieve this ?? Right now when i use StringFormat="{}{0:C}", "$" is being used

I have gone through this link and i am able to achieve the desired result but i am worried about using this in my project. Is this code safe ??

What does this line mean in the above link "when you test functionality related to settings change it’s important you start the program directly from a folder window, if you run it from within Visual Studio or any other program you may get incorrect results."


回答1:


You can specify the culture in your binding like this:

TextBlock Text="{Binding Value, StringFormat=C, ConverterCulture=nl-BE}" 

nl-BE is belgian culture, you can exchange it with Indian culture info, I don't know that ;-)




回答2:


Or you can set your current thread to the right culture, so you will use it everywhere in your application:

Thread.CurrentThread.CurrentUICulture = new CultureInfo("hi-IN");


来源:https://stackoverflow.com/questions/4734831/stringformat-in-xaml-wpf-currency-formatting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!