binding ListView to winmd IObservableVector / IList in C#


  • I am trying to bind to a component built in C# - one of the class members implements IObservableVector:

    public sealed class Class1
            public Class1() {...}
            public String MyString { get { ...} set {...} }
            public IObservableVector<object> MyVector
                    return (IObservableVector<object>)this._myObservableVector;
            private MyObservableVector<object> _myObservableVector;

    My HTML template:

            <h2 data-win-bind="textContent: myString WinJS.Binding.oneTime"></h2>
            <h2 data-win-bind="textContent: myVector WinJS.Binding.oneTime"></h2>
            <div data-win-control="WinJS.UI.ListView" data-win-bind="itemDataSource: myVector WinJS.Binding.oneTime" ></div>

    and the javascript code:

        var bindingSource = null;
        app.onactivated = function (args) {
                bindingSource = WindowsRuntimeComponent.CSharp.Class1();
                args.setPromise(WinJS.UI.processAll().then(function () {
                    WinJS.Binding.processAll(document.rootElement, bindingSource);

    The content in the first two items is correctly databound, but the ListView is empty. What am I missing? I've tried all sorts of permutations like switching to an ObservableCollection<> and sending back an IList<>, creating a bindable proxy via WinJS.Binding.as(bindingSource), etc.

    I found a couple of related forum posts but neither provided the insight I was looking for.

    - Tom

    Monday, July 30, 2012 4:50 PM

All replies