ListView Event Properties RRS feed

  • Question

  • I was wondering why WinJS.UI.ListView does not have "event properties" (those created using WinJS.Utilities.createEventProperties) for its events (iteminvoked etc). Is there a reason for that?

    It is a problem for me because I'm trying to bind a function to iteminvoked using the data-win-bind attribute [1]. It works fine with my custom controls that have event properties, but it does not with ListView. I can make it work by manually adding the event properties to the ListView in question [2], but that does not feel right.

    [1] (See this thread if you're wondering why I'm not using data-win-options)

    [2] like this: Object.defineProperties(listView.winControl, WinJS.Utilities.createEventProperties('iteminvoked'))

    Monday, May 14, 2012 4:23 PM

All replies

  • Hi G,

    You can trace in to see why this is failing.

    Put a Breakpoint on Line 392 of Base.js, debug and you should be able to see what is going on.  By inspection it looks like this should work fine for you!

    Realize this is creating an object that you would mix-in to your ListView.  It might be easier just to assign the event listener in your case however!


    Jeff Sanders (MSFT)

    Monday, May 14, 2012 5:41 PM
  • Hi Jeff,

    Thanks for looking into this. I have a workaround, it works. But:

    Why is there no oniteminvoked property on ListView objects that I can assign an event listener to? Is there a reason for that?

    I'm asking because it makes me a little sad that I have to give up on the concept of separating the view from the viewmodel, just because ListView has an incomplete event implementation (i.e. only supports addEventListener, but not oniteminvoked). With the current event implementation I have to get my ListView object in the code to either add the event listener manually (addEventListener) or add the event properties myself (see original post). Isn't this exactly what I'm trying to avoid by using declarative binding?

    // Guido

    Tuesday, May 15, 2012 7:06 AM