How to pass a bound value to Translate extension? Maybe I need Converter instead?

midixmidix LVMember ✭✭

I was trying to use the Translate extension from Xamarin examples:

In general, it works, I can use {i18n:Translate some_text_value}.

But I have a list of items and each item has a TextKey which needs to be translated. I don't want to pollute my CS code with manual calls to translator; I'd like to do it in XAML.

How do I make my bound values translated?

<ListView x:Name="someistView"> <ListView.ItemTemplate> <DataTemplate> <ImageCell Text="{Binding TextKey}" /> <-- how to get these translated through TranslateExtension ? </DataTemplate> </ListView.ItemTemplate> </ListView>

Is it possible at all? Maybe I should implement Translation ValueConverter instead?

Best Answer


  • please can you explain what method return "DependencyService.Get().Trans((string)value);" will do ?

Sign In or Register to comment.