tags:

views:

2082

answers:

2

Hi

In WPF 3.5SP1 i use the last feature StringFormat in DataBindings:

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

The problem i face is that the date is always formated in English...althought my system is in French ? How can i force the date to follow system date ?

thankd Jonathan

+16  A: 

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

From Creating an Internationalized Wizard in WPF

loraderon
Yea this is quite annoying. +1
siz
Thank you for resolving my headache.
Skurmedel
What about silverlight? It doesn't have OverrideMetadata method...
andrecarlucci
Great. But what to do if the culture changes during the lifecycle of the application (e.g. the user can change his preferred culture in a settings dialog). According to the documentation FrameworkElement.LanguageProperty.OverrideMetadata cannot be called more than once (it throws an exception)
huttelihut
A: 

Use Label (including Cultture) and not texblock

david