VansFannel VansFannel - 9 months ago 56
C# Question

WPF Binding StringFormat doesn't change the output

I'm developing a WPF with C# and .NET Framework 4.6.1.

I have this number 1010 and I want to show it like this 1.010 (I'm Spanish).

To do it, I have modified XAML:

<Label x:Name="labelCounterCamera" Margin="5,2"
Content="{Binding CounterCamera, StringFormat=N{0}}" />

But it shows the number without format: 1010.


public uint CounterCamera
get { return counterCamera; }

if (!value.Equals(counterCamera))
counterCamera = value;

Why that StringFormat doesn't work? What am I doing wrong?

Answer Source

you have to use ContentStringformat when using a Label

<Label x:Name="labelCounterCamera" Margin="5,2" 
   Content="{Binding CounterCamera}"
   ContentStringFormat="{}{0:N}" />