Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

StringFormat in XAML, WPF : Currency Formatting

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."

like image 950
Pankaj Upadhyay Avatar asked Jan 19 '11 11:01

Pankaj Upadhyay


2 Answers

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 ;-)

like image 153
Kim Breugelmans Avatar answered Sep 25 '22 15:09

Kim Breugelmans


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");
like image 33
Arcturus Avatar answered Sep 24 '22 15:09

Arcturus