0

Is there any way to use regional settings decimal separator in text boxes with binding StringFormat={}{0:N2} without handling the keydown or keypreview or whatever events?

It seems very trivial for me, but I can't figure out why it's so complicated to have a text box handling decimals correctly...

I know there is a lot of discussions on that subject, I won't accept to handle the keyX events... I don't want to create yet another control that do this for me while it should already exists...

Thanks,

Edit

Some precision : I want the textbox to know what decimal separator to use when typing Key.Decimal or Key.OemPeriod

Noone
  • 395
  • 1
  • 4
  • 17

2 Answers2

1

Have you tried setting the ConverterCulture in the binding?

<TextBlock Text="{Binding value, StringFormat=N2, ConverterCulture=de}" />
Alberto
  • 15,626
  • 9
  • 43
  • 56
  • I don't really understand the use of this property, but it's not working... http://msdn.microsoft.com/en-us/library/system.windows.data.binding.converterculture(v=vs.90).aspx – Noone Dec 04 '13 at 16:17
  • In this way will be used the separator (and the other format settings) of the culture specified in ConverterCulture – Alberto Dec 04 '13 at 16:51
0

this separates only decimals

textBox2.Text = string.Format("{0:0.00}",Convert.ToInt16(textBox1.Text));

format number in C#

Community
  • 1
  • 1
Ismail Gunes
  • 548
  • 1
  • 9
  • 24
  • My problem is when I want the text box to know what decimal separator to use when typing Key.OemPeriod or Key.Decimal – Noone Dec 04 '13 at 16:33