在 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)));
关于wpf - wpf 中的 StringFormat 本地化问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/520115/