WPF XAML StringFormat: Culture Workaround broken in C# 4.0?

女生的网名这么多〃 提交于 2019-11-30 22:25:01

1. Make sure you are overriding default value of LanguageProperty as early as possible. App's static constructor is the best bet. This is important because BindingExpression caches value of this property and does not reevaluate it afterwards for performance reasons.

2. What is your CultureInfo.CurrentCulture? Are you sure it's the one you expect to see?

3. Overriding Language property metadata has no effect if you you specify xml:lang attribute somewhere upper in the tree. E.g. if you say:

<StackPanel xml:lang="it">
  <TextBlock Text="{Binding StringFormat=C}"/>
</StackPanel>

You'll get Italian currency no matter what you set in property metadata.

4. Overriding Language property metadata has no effect if you specify ConverterCulture property in binding. E.g. if you say: <TextBlock Text="{Binding StringFormat=C, ConverterCulture=ja}"/> you'll get Japanese currency no matter what you set either in property metadata or in xml:lang attribute.

This behavior was not changed between frameworks as far as I know.

Hope this helps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!