Binding string from Resources.resjson in ListView template


  • Hello,

    I have a ListView with some template (in this case it's a group header). I bind the p textContent to the underlying list item.

    <div class="headerTemplate" data-win-control="WinJS.Binding.Template">
        <p class="group-title win-type-x-large" data-win-bind="textContent: title WinJS.Binding.oneTime; groupKey: key WinJS.Binding.oneTime"
            onclick="WinJS.Navigation.navigate('/pages/groupDetail/groupDetail.html', { groupKey: event.srcElement.groupKey })" role="link">

    Now I began localizing my app so what I need to do is to bind the localized group header title from the resources file. How can I do that, i.e. reference the data item and resource label at the same time?


    Wednesday, August 01, 2012 12:05 PM


All replies

  • Hi

    To help localize a Metro style app, you can add one or more Resources File item templates (.resjson files) to your project.

    For more  info, see Globalizing your app, it provide a best practice scenario to globalize and localize your Metro style app.

    Hope it helpful.

    Friday, August 03, 2012 9:43 AM
  • Hi,

    I already have .resjson file and I'm able to successfully bind static text. But what about binding inside a ListView template? Let's say my datasource contains strings like "LABEL_1" and "LABEL_2", and I'd like to bind these identifiers to resource file so that user eventually sees "LABEL_1" and "LABEL_2" in his own language.

    Hope I didn't complicate it too much ;) Thanks.

    Friday, August 03, 2012 9:48 AM
  • Hi

    You should have different language Datasource.

    If you use a web service, you need to provide each language version.

    For example you request data from a web service, request string is:

    var userInputLanguage = Windows.Globalization.Language.currentInputMethodLanguageTag;

    var requestStr = "http://www.webservice.net/json.aspx?";


    If your current input language is US English this requestStr will be http://www.webservice.net/json.aspx?language=en-us

    Then do the binding as usual.

    If you use Other data source you can also refer to this experience.

    Here is a example about Listview working with datasource and another example about Application resources and localization sample.

    • Marked as answer by Docentus Monday, August 06, 2012 12:22 PM
    Monday, August 06, 2012 11:09 AM
  • Hi,

    Seems reasonable to have a language distinction in the datasource, thanks for the tip :)


    Monday, August 06, 2012 12:23 PM