data-win-options attribute
Réduire la table des matières
Développer la table des matières

data-win-options property

[This documentation is preliminary and is subject to change.]

Applies to: Metro style apps only

Sets the specified properties and values for a Windows Library for JavaScript control.


<div data-win-control="control" data-win-options="{ property : value}" />

Property value

Type: String

One or more property : value pairs. Separate multiple property : value pairs with commas.


When you create an HTML control, you can set its properties using dedicated attributes. For example, to set the type, min, and max properties of an input control, you can set the type, min, and max attributes in your markup:

<input type="range" min="0" max="20" />

Unlike HTML controls, Windows Library for JavaScript controls don't have dedicated element or attribute tags; for example, you couldn't create a Rating control and set its properties using the following markup:

<!-- Not valid markup. -->
<rating maxRating="10" averageRating="6" />

Instead, you use the data-win-options attribute to set a property in markup. The data-win-options attribute uses the following syntax:

data-win-options="{propertyName: propertyValue}"


To set multiple properties, you separate them with a comma:

data-win-options="property1Name: property1Value, property2Name: property2Value"


The following example creates a Ratings control and sets its maxRating and averageRating properties.

<div data-win-control="control" data-win-options="{ property : value}" />

For a list of properties supported by a given Windows Library for JavaScript control, see its reference page.

You can also set the properties of a Windows Library for JavaScript control programmatically. To access the control in code, you call the WinJS.UI.getControl function to retrieve the control from its host element.


Minimum supported client

Windows 8 Consumer Preview

Minimum supported server

Windows Server 8 Beta

See also

Quickstart: adding WinJS controls



Build date: 2/10/2012

Ajouts de la communauté

© 2016 Microsoft