Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Culture dependant formatig of digit grouping issue

$
0
0

Dear all,

I have an application which is culkture dependant for which I shold be able to display value based on current culture

For that I have a snipet of a single binding as below :

Data="{Binding Value,Converter={StaticResource DataConverter}

In Value is a digit as 1234, then if I am in :

- US english culture Data should be formated and display as 1,234
- Frenc culture Data should be formated and display as 1234

When I use a converter I have notice that the Culture paramter is all time set to US-English. In order that WPF take care of region settign change I have added in my app.xaml followinf code in OmnStartup:

FrameworkElement.LanguageProperty.OverrideMetadata(
			typeof(FrameworkElement),
			new FrameworkPropertyMetadata(
				XmlLanguage.GetLanguage(
				CultureInfo.CurrentCulture.IetfLanguageTag)));

My converter is as simple as below :

public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is double)
            {
                 if (value >= 1000)
              {
                //higher than 1000 incl
                return value.ToString("N0"); //xxxx
            }
            }

			return value;
			//return (string)value;

		}

When I am in english all is fine but as soon as I switch in Frenc for instance I get an exception input string not in correct format when the binding occurs.

Any idea how to solve the issue

regards


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>