wpf中的StringFormat本地化问题 [英] StringFormat Localization issues in wpf

查看:16
本文介绍了wpf中的StringFormat本地化问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 WPF 3.5SP1 中,我使用 DataBindings 中的最后一个功能 StringFormat:

In WPF 3.5SP1 i use the last feature StringFormat in DataBindings:

     <TextBlock Text="{Binding Path=Model.SelectedNoteBook.OriginalDate, StringFormat='f'}"
                FontSize="20" TextTrimming="CharacterEllipsis" />

我面临的问题是日期总是用英文格式化......虽然我的系统是法文的?如何强制日期跟随系统日期?

The problem I face is that the date is always formatted in English...although my system is in French ? How can i force the date to follow system date?

推荐答案

// Ensure the current culture passed into bindings is the OS culture.
// By default, WPF uses en-US as the culture, regardless of the system settings.
FrameworkElement.LanguageProperty.OverrideMetadata(
      typeof(FrameworkElement),
      new FrameworkPropertyMetadata(
          XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

来自 在 WPF 中创建国际化向导

这篇关于wpf中的StringFormat本地化问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆