为什么WPF会忽略我的CultureInfo.CurrentCulture

问题描述 投票:0回答:1

我开始弄乱MySQL.Data.EntityFramework(8.0.15)并且我的日期格式错误。

在我的文化('pl-PL')日期格式是“YYYY-MM-DD”,但DataGrid默认以“MM / DD / YYYY”格式显示日期。我的Windows区域设置是正确的。

Console.WriteLine(CultureInfo.CurrentCulture); // shows pl-PL

我的绑定最初是这样的:

<!-- wrong date format -->
Binding="{Binding date}" 

在Binding中设置ConverterCulture:

<!-- correct date format -->
{Binding date, ConverterCulture='pl-PL', StringFormat=d}

但我不想在任何地方设置ConverterCulture。

我的问题是:

我怎样才能解决这个问题?

mysql wpf entity-framework binding cultureinfo
1个回答
1
投票

尝试设置

Thread.CurrentThread.CurrentUICulture

也许,你需要看一看

FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(
    XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
© www.soinside.com 2019 - 2024. All rights reserved.