AppBar.Hide隱藏Windows Phone上的輔助命令欄,而不是主AppBar。如果你想讓整個AppBar消失,那麼這不是合適的屬性。
最簡單的方法是在要顯示它的頁面上聲明AppBar,並將它放在不需要的頁面上,但是應該可以通過在頁面上禁用AppBar來隱藏它你不想要它。
我只是修改了HTML AppBar control sample的appbar,commands.js如下文件和appbar隱藏和顯示我點擊隱藏和顯示按鍵:
// These functions are used by the scenario to show and hide elements
function doShowItems() {
document.getElementById('commandsAppBar').winControl.disabled = false;
//document.getElementById('commandsAppBar').winControl.showCommands([cmdFavorite, cmdCamera]);
document.getElementById('scenarioShowButtons').disabled = true;
document.getElementById('scenarioHideButtons').disabled = false;
}
function doHideItems() {
document.getElementById('commandsAppBar').winControl.disabled = true;
//document.getElementById('commandsAppBar').winControl.hideCommands([cmdFavorite, cmdCamera]);
document.getElementById('scenarioHideButtons').disabled = true;
document.getElementById('scenarioShowButtons').disabled = false;
}
我也與單頁導航證實模型在兩頁之間導航。如果你沒有看到appbar隱藏並顯示禁用和啓用時,請確保你正在調用代碼來禁用/啓用appbar。返回到緩存頁面時,PageControl的ready函數可能不會被調用。
我不確定Winjs,但在C#中,當您設置BottomAppBar = null時,您肯定可以隱藏AppBar。也許你可以嘗試類似的東西。 – Romasz 2014-09-28 19:40:14
是的,我知道如何在C#中做到這一點。但我的要求是WinJS。我完全沉迷於如何做這樣一件簡單的事情。 – 2014-09-29 08:41:04