SettingsFlyout - how to populate controls


  • Hi I am using the new SettingsFlyout control for the settings charm. I am using this code to call the settings page:

            WinJS.Application.onsettings = function (e) {
                e.detail.applicationcommands = { "settingsDiv": { title: "Configuration", href: "/html/settings.html" } };

    On the settings.html file I have a dropdown control (HTML SELECT) that needs to be populated dynamically from an array of values and the selected option must correspond to a localSettings variable, when the dropdown changes that localSettings variable must be updated.

    I tried several ways to populate dropdown control but it seems that any changes made after "WinJS.UI.SettingsFlyout.populateSettings" line does not affect the flyout.

    How is the correct way to populate controls in the SettingsFlyout dynamically?


    2012년 3월 7일 수요일 오전 4:01


모든 응답

  • You would do that in the js behind your page.

    See the sample:

    Scenario 4 is a good starting point.  Populate your controls in the js file referenced by the html page.

    Jeff Sanders (MSFT)

    2012년 3월 7일 수요일 오후 8:31
  • Hi Jeff, thanks for the reply. I followed the example, and added code to populate dropdown in "beforeshow" event of the settings flyout control but the dropdown remains empty as its inicial state.

    What I did to solve this, and I am not sure if it is a correct solution, is to add a Page Control to the solution and use that page as the settings page. Then on the "ready" function of the PAge control I added the code to initialize dropdown.

    Is this a good approach for a settings page?



    2012년 3월 26일 월요일 오후 5:54
  • Yes, you can also use the WinJS.Pages.define("/html/settings.html")
    to register a Page object with a "ready" function that will be called whenever the settings fragment is loaded.

    Works better and is cleaner than this awkward mixing of script code into markup like in the sample code.

    • 편집됨 phil_ke 2012년 3월 27일 화요일 오후 1:28
    • 답변으로 표시됨 Bob_BaoMVP 2012년 4월 10일 화요일 오전 3:43
    2012년 3월 27일 화요일 오후 1:27