Windows 8.1: WinJS: appbar won't open/show by default?
NickName:Chris Spittles Ask DateTime:2014-01-09T20:18:46

Windows 8.1: WinJS: appbar won't open/show by default?

I'm working on a Windows 8.1 app and on a data input page I would like the appBar to be open or visible by default as it contains the option to save the data.

http://msdn.microsoft.com/en-us/library/windows/apps/br229676.aspx

I've looked at the link above and tried the show method in the following way:

Markup:

<div id="appbarCommands" data-win-control="WinJS.UI.AppBar" data-win-options="{sticky: 'true'}">
    <button data-win-control="WinJS.UI.AppBarCommand"
            data-win-options="{id:'cmdSaveCustomer', icon:'save', section:'global'}"
            data-win-res="{winControl: {label:'CRM_contactHistory_appBar_SaveLabel', tooltip:'CRM_contactHisory_appBar_SaveToolTip'}}"></button>
</div>

JS Code:

(function () {
        "use strict";

    WinJS.UI.Pages.define("/pages/CRM/customerDetails/contacts/contactHistory/contactHistory.html", {

        ready: function (element, options) {

            WinJS.UI.processAll().done(function () {

                setAppBarState(document.getElementById("appbarCommands"));

            });
            WinJS.Resources.processAll()            
        }
    });
})();

function setAppBarState(appBar) {

    appBar.winControl.show();

}

For whatever reason, the appBar doesn't launch. I've tested it in the appBar sample code and it works fine on there, but it doesn't work in the actual solution.

I wondered if someone could perhaps shed some light on the problem? Or perhaps knows of a reason that would prevent the appbar being shown when the page loads?

Many thanks

Chris

Copyright Notice:Content Author:「Chris Spittles」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/21020060/windows-8-1-winjs-appbar-wont-open-show-by-default

Answers
Kraig Brockschmidt - MSFT 2014-01-14T16:59:55

Add the sticky property in your data-win-options in the HTML:\n\ndata-win-options=\"{ sticky: true }\"\n\n\nThen using show() should work just fine. I tested this in the HTML Appbar control sample and it worked.\n\nAlso, you don't need to call WinJS.UI.processAll within the ready method--processAll is called automatically when a page control is loaded. (The same is not true for WinJS.Resources.processAll, just UI.processAll.)",


More about “Windows 8.1: WinJS: appbar won't open/show by default?” related questions

Windows 8.1: WinJS: appbar won't open/show by default?

I'm working on a Windows 8.1 app and on a data input page I would like the appBar to be open or visible by default as it contains the option to save the data. http://msdn.microsoft.com/en-us/library/

Show Detail

Add AppBarCommand to AppBar in WinJS

I need to add an AppBarCommand to an AppBar programmatically. This used to work on Windows 8.1, but it's not working on Windows 10. I receive no errors, but when I execute the below code, my

Show Detail

Will WinJS.UI.AppBar work on browsers?

I have used WinJS and it works on Browsers. However, the WinJS site does not have examples for other controls like Win.UI.AppBar that can be used in Win8.1 or Win10. Will WinJS.UI.AppBar work on

Show Detail

Windows Phone 8.1 WinJS Appbar disabled property not working

I'm trying to hide (disable) the appBar so it doesn't show on up a page in my app. However the disabled property doesn't seem to be working, or my syntax is off. I've tried using it like: &lt;scri...

Show Detail

Windows 8.1 AppBar Ellipsis

In Windows 8.1 RTM apps like Calendar come with an AppBar with ellipsis. I'm trying to replicate that but can't find any details on such functionality being added to the AppBar control in Windows ...

Show Detail

windows phone8.1 support winjs/javascript as native already?

I'm wondering if the Windows Phone 8.1 SDK supports WinJS? I saw there are some news that windows phone 8.1 start to support WinJS If so, I will move to WinJS for WP and WinRT both. Your comment

Show Detail

Does windows phone8.1 sdk support winjs/javascript as native

I used C# develop a WP8 app. I'm wondering if the Windows Phone 8.1 SDK supports WinJS? I saw there are some news that windows phone 8.1 start to support WinJS If so, I will move to WinJS for WP ...

Show Detail

Windows Phone 8.1 WinJS AppBar disappears when navigating to another page containing an AppBar

I have two Pivot pages each with their own unique AppBar. The second pivot page, is accessible through the first pivot page via the AppBar. However, when I visit the second pivot page, its correspo...

Show Detail

Windows Phone 8.1 WinJS AppBar disappears if I leave the app (suspended) and go back inside

Everything works perfectly. The appbar is displayed only in the home, but if I exit the App without closing and again opening it, it disappears the appbar In home.js WinJS.UI.Pages.define("/page...

Show Detail

WinJS.UI.Flyout HTML on windows phone 8.1

I am trying to create a WinJS.UI.Flyout with a single input field and a single button to allow the user to enter a new value in the input field and click on the button to save it. However, on windows

Show Detail