开发者

WPF String Format With Custom Separator

I need to format a number using String Format in XAML such that

 12345678901 -> "123456.78901"
  2345678901 -> "023456.78901" 

When I write write

<TextBox Text="{Binding TheNumber, StringFormat={}{0:000000.00000}}"/>

I end up getting:

12345678901 -> "12345678901.00000"

For experimentation, I try replacing the dot with a space:

<TextBox Text="{Binding TheNumber, StringFormat={}{0:000000 00000}}"/>

and get:

12345678901 -> "123456 78901"

I would like a behavior similar to the last example, only with a "dot"-speparator instead of "space".

Anyone know how to do this using XAML only?

Thanks!

Edit: I just figured that I need to escape the "dot", which reg开发者_StackOverflow中文版ularly is treated as a decimal point:

<TextBox Text="{Binding TheNumber, StringFormat={}{0:000000\\.00000}}"/>


Try it like this

<TextBox Text="{Binding TheNumber, StringFormat={}{0:000000'.'00000}}"/>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜