Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

Can a parameter be passed in a binding?

$
0
0

Is it possible to use an indexer in a property in the Data Model? Then include that in the binding parameter?

What I'd like to do, for internationalization, is have a Translator class which will return a literal based on a key/value table. So rather than litter my View Model with tons of string properties I'd like to something like this:

Label Text="{Binding Translation[1]}" /
Label Text="{Binding Translation[2]}" /
Label Text="{Binding Translation[3]}" /
...
(The integers could be enums of course)

The View model would have a property like this:

public string Translation[int index]

        get

            return myTranslatorClass.Literals[index] ;

instead of dozens of individual properties for each string

(Have to figure out how to paste code)

For example, element 1 in the English table might be "Please enter your password"
but if the Bulgarian string file is loaded it would return "Моля, въведете паролата"


Viewing all articles
Browse latest Browse all 91519

Trending Articles



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