Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8060987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:10:42+00:00 2026-06-05T10:10:42+00:00

First off, is there any list of properties that can be set when using

  • 0

First off, is there any list of properties that can be set when using data-win-bind attribute in your markup?

A few things I am looking to do:

  1. Conditionally append a classname based on the datasource.
  2. Declare event listeners within the markup. Would like these event listeners to exist on the datasource and NOT some global function.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:10:44+00:00Added an answer on June 5, 2026 at 10:10 am

    There are two sets of properties that you can bind to.

    The first is the properties supported in the DOM by each element type. So, for an img element, for example, you can bind the src property to set the image that is displayed. For an input element you can bind to the value property. You can see a complete list of the HTML elements that are available for Metro apps here.

    The second set of properties is available if you have applied a WinJS UI control to an element (which is usually done with the data-win-control attribute. You can set the properties defined by each control via the winControl property which is added when the control is applied. As an example, if you wanted to bind the itemTemplate property in a ListView, you would have markup like this:

    <div id="list" data-win-control="WinJS.UI.ListView"
        data-win-bind="winControl.itemTemplate: myValue"></div>
    

    You can use the same technique to set your event handlers. Define the callback functions as part of your data source like this:

    var dataSource = {
        myClickHandler: function (e) { console.log("Click!") }
    }
    

    And then bind to the on* property that corresponds to the event you are interested in:

    <button data-win-bind="onclick: myClickHandler">Press Me</button>
    

    Adding and removing individual classes is much trickier. I find that the easiest way to do it is with a code-based binding. Create an observable property in your data source like this:

    var dataSource = {
        myClickHandler: function (e) { console.log("Click") },
        classes: WinJS.Binding.as({
            myFirstClass: true,
            mySecondClass: false,
        })
    }
    

    And then use the bind method on the observable object to get notifications when the value changes and apply/remove the class, as follows:

    dataSource.classes.bind("myFirstClass", function (newValue) {
        var elem = document.getElementById("myId");
        if (newValue) {
            WinJS.Utilities.addClass(elem, "myFirstClass");
        } else {
            WinJS.Utilities.removeClass(elem, "myFirstClass");
        }
    });
    

    You can bind classes declaratively, but you need to set all of the classes in one go, which is rarely that useful. If you want to go that approach, then you bind the className property on the element.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, I'm using the Qt 4 libraries and C++. Is there a way
First off, if there is a true, official way of having flash/flex's NetConnection s
First off I have an app that provides the user information about the amount
First off, I have read through a list of postings on this topic and
I recently wrote, my first, WPF application that has a list of items that
First off, does anyone have a comprehensive list of the Perl special variables? Second,
Is there any JS/CSS/jQuery magic I can work to identify whether the last visible
Are there any examples out there that will allow me to remove options from
First off, this example will only work in a browser that supports :nth-child ,
First, I'll start off by saying that I do not have control over the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.