wpf - wpf 中的 StringFormat 本地化问题

标签 wpf datetime localization

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

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

我面临的问题是日期始终采用英语格式...尽管我的系统是法语?如何强制日期遵循系统日期?

最佳答案

// 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)));

来自Creating an Internationalized Wizard in WPF

关于wpf - wpf 中的 StringFormat 本地化问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/520115/

相关文章:

c# - 带有 WPF 菜单控件的下拉列表

c# - 我可以从具有多个轴的 oxyplot 图表中删除裁剪吗?

python - 从系列中删除分钟和小时

objective-c - 首选语言 iOS 9

ios - 带背景的本地化 UILabel

wpf - 如何突出显示列表框中的匹配子字符串?

c# - 使用 32feet.net 使用独特的服务协议(protocol)连接到 BTLE 设备

python - 将特定时间量添加到日期时间列

c# - 无法将 'System.TimeSpan?' 隐式转换为 'System.TimeSpan'

时间:2019-03-17 标签:c#SetupProjectLocalization