Adding a WinJS control in JavaScript code in Windows 10 App

You can add the WinJS control to the page in the markup page or from your javascript code.

How to add a WinJS control in your JavaScript code for Windows 10 Apps ?

Add the element in the markup (HTML page) that will host your control.

<div id="element"></div>

In your JavaScript code , retreive the element using the document.getElementById method.

var containerElement = document.getElementById("element");

You can now start creating the control (for example : Rating Control) by passing the containerElement to the constructor.

var ratingControl = new WinJS.UI.Rating(containerElement ); 

When you run the Windows 10 app and view the page , you should see the RatingControl displayed in the screen.

Leave Your Comment

Liked this content?. Please spread the word :)