currentculture

Use “real” CultureInfo.CurrentCulture in WPF Binding, not CultureInfo from IetfLanguageTag

余生颓废 提交于 2019-12-17 06:39:20
问题 In my case: I have a TextBlock Binding to a property of type DateTime. I want it to be displayed as the Regional settings of the User says. <TextBlock Text="{Binding Date, StringFormat={}{0:d}}" /> I am setting Language property as WPF XAML Bindings and CurrentCulture Display says: this.Language = XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag); But with this line of code it just displays the text as the default format of CultureInfo with IetfLanguageTag of CurrentCulture

How to set current CultureUI via XAML binding

对着背影说爱祢 提交于 2019-12-12 19:56:46
问题 I have a TextBlock bound to a string. I want the string to be displayed in current UI culture of the application. I want to do this in XAML. The text block is simple like below. <TextBlock Text="{Binding Path=Text}"/> 回答1: You need to set the FrameworkElement.Language property. The easiest way to do that for the whole application is to override the property metadata in the App class static constructor: public partial class App : Application { static App() { FrameworkElement.LanguageProperty

Culture specific DateTime string is inconsistent between platforms

岁酱吖の 提交于 2019-12-12 15:23:17
问题 I have a test application that allows the user to select a culture from a ComboBox and displays the culture specific date in a multiline TextBox. The code is below: public partial class Form1 : Form { public Form1() { InitializeComponent(); comboBox1.Items.AddRange( CultureInfo.GetCultures(CultureTypes.SpecificCultures)); } private void comboBox1_SelectedValueChanged(object sender, EventArgs e) { CultureInfo selectedCulture = comboBox1.SelectedItem as CultureInfo; DateTime currentDate =

ASP.Net MVC switching Cultures after compile for initial load

廉价感情. 提交于 2019-12-10 19:04:05
问题 I have a hybrid ASP.Net web forms/MVC app. On one of the MVC "pages"/views, I have it render a bunch of dates using the ToShortDateString() and ToLongDateString(). These work correctly most of the time, but the first time I load the view after compiling the app, they are formatted incorrectly. I traced this down and checked the current thread's culture. For 99% of the time it's en-US, but on the first load of the MVC view after compiling it is set to en-GB. If I reload the page immediately

Why doesn't the Timezone change when I set the CurrentCulture?

丶灬走出姿态 提交于 2019-12-08 18:41:50
问题 From what I have researched it is not possible to change the Timezone of a thread. So my question is why can't you? I would have thought switching your application's culture to a specific country would also switch this, seems like expected behaviour IMO. Edit After revising I can see the reason why it probably shouldn't be mapped 1:1 by default. However, I still feel it would be a nice feature to be able to change the Timezone per thread. 回答1: They aren't a 1:1 so they're not really connected

What is setting CultureInfo.CurrentCulture

巧了我就是萌 提交于 2019-12-01 18:30:31
问题 If I do a Console.WriteLine(System.Globalization.CultureInfo.CurrentCulture.ToString()); get "en-US" What should I change in my control panel settings ( Region and Language ? ) to get something else for example "en-CA" . 回答1: In my experience, the culture was set by the version of the operating system. Not really a setting in the control panel. We used to have to have multiple VM's running multiple version of Windows to test our cultural based features 回答2: What should I change in my control

What is setting CultureInfo.CurrentCulture

六眼飞鱼酱① 提交于 2019-12-01 17:59:07
If I do a Console.WriteLine(System.Globalization.CultureInfo.CurrentCulture.ToString()); get "en-US" What should I change in my control panel settings ( Region and Language ? ) to get something else for example "en-CA" . In my experience, the culture was set by the version of the operating system. Not really a setting in the control panel. We used to have to have multiple VM's running multiple version of Windows to test our cultural based features What should I change in my control panel settings ( Region and Language ? ) to get something else for example "en-CA" . You can change it for

Windows Service Unable to get correct System Culture

北慕城南 提交于 2019-12-01 00:56:27
From Control Panel, I set my Region and Language setting to French (France) When I am running my application as console application, Thread.CurrentThread.CurrentCulture returns French But when I'm running it as windows service, it returns invariant culture or English (US) Is there a way to fix that? The service is probably running as a user that has it's own culture. Why not set the culture when you start your service Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR"); Also from Default Culture in a Windows Service

Windows Service Unable to get correct System Culture

放肆的年华 提交于 2019-11-30 20:01:45
问题 From Control Panel, I set my Region and Language setting to French (France) When I am running my application as console application, Thread.CurrentThread.CurrentCulture returns French But when I'm running it as windows service, it returns invariant culture or English (US) Is there a way to fix that? 回答1: The service is probably running as a user that has it's own culture. Why not set the culture when you start your service Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); Thread

When should I specify CurrentCulture or InvariantCulture and when should I leave it unspecified?

末鹿安然 提交于 2019-11-30 08:12:59
What is the best practice for specifying CurrentCulture or InvariantCulture and not specifying the culture at all? From what I have read, if you're doing serialization, for instance, you need InvariantCulture as a means of specifying a canonical representation of a data value. That's a relatively small percentage of culture-based string manipulations. I find it long, verbose, and ugly most of the time to specify it every time I do, say: var greeting = string.Format(CultureInfo.CurrentCulture, "Hello ", userName); However, my team recently turned FxCop on and now there's a push to always use