Answered by:
How to change converter language parameter to culture info?

Question
-
I'm porting over some converters from Windows Phone to WinRT. Here is a sample converter:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
var resourceName = value.ToString() as string;
return local.ResourceManager.GetString(resourceName, culture);
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}If I change the System.Globalization.CultureInfo culture parameter to a string language parameter to make the Convert() call compatible with WinRT's IValueConverter interface, how do I convert the string language parameter to a System.Globalization.CultureInfo value the GetString() call understands?
-- roschler
Friday, January 24, 2014 11:33 PM
Answers
-
I was asking you why you didn't want to use the CultureInfo(String) constructor.
- Marked as answer by Jamles HezModerator Monday, February 3, 2014 7:25 AM
Sunday, January 26, 2014 5:35 PMModerator -
Hi
As Rob suggested you can use various culture specific formats.
CultureInfo deDe= new CultureInfo("de-De");
where you can specify the culture format based on country/region.
Regards
Varun Ravindranath
- Marked as answer by Jamles HezModerator Monday, February 3, 2014 7:25 AM
Sunday, January 26, 2014 7:12 PM
All replies
-
Build it from the CultureInfo(String) constructor?
Saturday, January 25, 2014 1:23 AMModerator -
Thanks Rob. Sounds good but you posed your answer as a question. Is there a possible shortfall to this approach?
-- roschler
Saturday, January 25, 2014 2:46 PM -
I was asking you why you didn't want to use the CultureInfo(String) constructor.
- Marked as answer by Jamles HezModerator Monday, February 3, 2014 7:25 AM
Sunday, January 26, 2014 5:35 PMModerator -
Hi
As Rob suggested you can use various culture specific formats.
CultureInfo deDe= new CultureInfo("de-De");
where you can specify the culture format based on country/region.
Regards
Varun Ravindranath
- Marked as answer by Jamles HezModerator Monday, February 3, 2014 7:25 AM
Sunday, January 26, 2014 7:12 PM