WPF StringFormat={0:C} showing as dollars

Why does this line of code

<TextBlock Text="{Binding Net, StringFormat=c}"/>

Output the result as $xx.xx when all my regional settings are set to UK. I expect it to output it as £xx.xx. Any ideas? I have tried different variations of the stringformat including StringFormat={}{0:C} but still get the same result.

Thanks for looking.

How to convert decimal to string value for dollars and cents separated in C#?

I need to display decimal money value as string, where dollars and cents are separate with text in between. 123.45 => 123 Lt 45 ct I came up with the following solution: (value*100).ToString(#0

WPF StringFormat={}{0:N} Error “Expected ‘”

I’m getting an error in VS 2008 SP1 with WPF using the stringformat binding, is there an inherent problem with wpf in vs 2008? Error 1 Expected ‘ ConstituentCrossrateGridControl.xaml 70 141 PriceViewW

WPF Databinding StringFormat does not support hex format?

I am using WPF databinding. I can format the number if I specify StringFormat={}{0:C}. However, if I use StringFormat={}{0:X2}, it will give give the following exception: System.Windows.Data Error: 6

Javascript showing in dollars!

How would I display JavaScript output numbers in dollar format? I.E. $20.00 then $2,000.00 when the number gets larger. Ok so sample code. if(this.getField(Account Name RequiredRow1).value !=) { e

Dollars and Cents (JAVA)

I need help with the calucluations for this java project i’m working on. The assignment asks me write a program that will spell out the number of dollars & cents based on a user numeric input. So,

Is there a way to make XAML / C# StringFormat show whole dollars for larger amounts but cents for smaller amounts?

In XAML, it is easy enough to use StringFormat=’$#,0;$-#,0;Nil’ to make a bound integer variable display as a nicely formatted dollar amount. e.g., 1024 would come out as ‘$1,024’. I have a need to de

WPF StringFormat negative value issue

I’m using The following format string in a WPF binding: StringFormat={}{0:Gain: 0 dB} And when the bound value goes negative I get: -Gain: 1234 dB My desired output is Gain: -1234 dB. Can someone

WPF Popup UI showing black

I am using a WPF Popup control, and it is showing the background as black. I put a StackPanel inside it with Background=Transparent, but that does not help. <Popup PlacementTarget={Binding Eleme

Searching in WPF comboBox showing two columns

I have to enable searching in WPF comboBox showing two columns in my WPF MVVM application. Below is my code which is showing two columns like : First Name – Last Name <ComboBox Grid.Column=3 Gri

C# WPF – TextBox is not showing the characters

I was programming in C # WPF, I’ve customized the style of a text box, and now he’s not sampling the characters. <Window.Resources> <Style x:Key=wwindow TargetType={x:Type Window}> &lt

Answers

I’m not sure if this has been fixed in .NET 4, but WPF has never picked up the current culture when rendering things like currency or dates. It’s something I consider a massive oversight, but thankfully is easily corrected.

In your App class:

protected override void OnStartup(StartupEventArgs e)
{
    FrameworkElement.LanguageProperty.OverrideMetadata(
        typeof(FrameworkElement),
        new FrameworkPropertyMetadata(
            XmlLanguage.GetLanguage(
            CultureInfo.CurrentCulture.IetfLanguageTag)));
    base.OnStartup(e);
 }

See this excellent post for more information.

What works for me:
1) In app.xaml override OnStartup() and add – System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(“et-EE”);

2) Define in XAML @ Window level – xmlns:sysglb=”clr-namespace:System.Globalization;assembly=mscorlib”

3) In XAML – <TextBox Text=”{Binding Path=Price, StringFormat='{}{0:C}’, ConverterCulture={x:Static sysglb:CultureInfo.CurrentUICulture}}” />

This correctly picks up any custom regional settings. Although I’m using a manually created CultureInfo in the first step, I’m sure it’s possible to pass in one of the static types – eg. System.Globalization.CultureInfo.CurrentCulture (I haven’t tested it though…)

I do Language=”en-GB” in the main window e.g.

<Window x:Class="AllocateWPF.Vouchers"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Test" Height="692" Width="1000" Language="en-GB">