我将创建一个基类,您的所有页面都在该基类上派生,并为那里的文化设置所需的参数,如下所示:
public class PageBase : Page
{
protected override void InitializeCulture()
{
var culture = CultureInfo.CreateSpecificCulture( CultureInfo.CurrentCulture.Name );
culture.NumberFormat.CurrencySymbol = string.Empty;
culture.NumberFormat.NumberDecimalDigits = 2;
culture.NumberFormat.NumberDecimalSeparator = ".";
culture.NumberFormat.NumberGroupSeparator = ",";
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
base.InitializeCulture();
}
}
或者您可以在现有文化的基础上建立您的文化:
public class PageBase : Page
{
protected override void InitializeCulture()
{
var culture = CultureInfo.CreateSpecificCulture( "en-US" );
culture.NumberFormat.CurrencySymbol = string.Empty;
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
base.InitializeCulture();
}
}