Search code examples
javascriptuisplitviewcontrollerwinjswin-universal-app

In WinJS, How Do I Call openPane()?


What I want:

A button on a closed splitView that calls .openPane().

What I've tried:

This MSDN documentation says that SplitView should have a method called showPane(). Looking at this codepen example makes it seem like I can just WinJS.Namespace.define() a random var, put a splitView: null on it and have it all work but it complains that openPane() is not a supported method or property. Looking at the code Visual Studio 2015 generates, I would expect to call window.mySpitView.splitView.openPane() which complains about splitView being null (because it's set to null at the top). I also tried doing WinJS.UI.SplitView.openPane() which also complains that .openPane() is not a supported property or method.

I'm using Visual Studio 2015 and WinJS 4.X (I installed fresh from NuGet so it had better be the most recent)


Solution

  • Your instance of the SplitView has the openPane. You're calling it as a static method which just isn't there. Find your SplitView with some selector like the following

    var splitView = document.querySelector('[data-win-control="WinJS.UI.SplitView"]');
    splitView.winControl.openPane();
    

    That should do the trick