Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/magento/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 8 隐藏时WinJS AppBar按钮闪烁_Windows 8_Winjs_Appbar - Fatal编程技术网

Windows 8 隐藏时WinJS AppBar按钮闪烁

Windows 8 隐藏时WinJS AppBar按钮闪烁,windows-8,winjs,appbar,Windows 8,Winjs,Appbar,我的应用程序在屏幕底部有一个WinJS AppBar控件。我使用.showOnlyCommand(buttonsToShowArray)来显示和隐藏列表视图上的按钮 我现在遇到的问题是,每当我调用.showOnlyCommand时,要隐藏的按钮(或者您可以说“已替换”)将在屏幕顶部闪烁 我尝试使用Microsoft示例应用程序,但没有发生这种情况。我尝试使用.showCommands+.hideCommands方法,这是相同的行为。请注意,在发布Win8预览版之前,这种情况不会发生 我不知道发生

我的应用程序在屏幕底部有一个WinJS AppBar控件。我使用
.showOnlyCommand(buttonsToShowArray)
来显示和隐藏
列表视图上的按钮

我现在遇到的问题是,每当我调用
.showOnlyCommand
时,要隐藏的按钮(或者您可以说“已替换”)将在屏幕顶部闪烁

我尝试使用Microsoft示例应用程序,但没有发生这种情况。我尝试使用
.showCommands
+
.hideCommands
方法,这是相同的行为。请注意,在发布Win8预览版之前,这种情况不会发生

我不知道发生了什么事。有什么想法吗

编辑:
我做了进一步的调查,问题发生在
隐藏命令上。假设应用程序栏上显示了3个按钮。我调用
hideCommand
隐藏所有3个按钮。3个按钮的图标将在appbar上消失,然后堆积在屏幕的左上角,然后消失。(即在屏幕的一角会有3个堆叠的按钮闪烁)

当AppBar处于“显示”过程中时,您可能正在调用ShowOnlyCommand。我发现在beforeshow或aftershow处理程序中调用这些方法时会发生这种情况。这句话揭示了为什么:

使用淡入淡出动画显示或隐藏瞬态UI或控件。一个例子是在一个应用程序栏中,由于用户交互,可以在其中显示新控件


示例应用程序在显示appbar之前显示/隐藏按钮。在调用ShowOnlyCommand之前,您可能正在应用程序栏上调用show

当AppBar处于“显示”过程中时,您可能正在调用ShowOnlyCommand。我发现在beforeshow或aftershow处理程序中调用这些方法时会发生这种情况。这句话揭示了为什么:

使用淡入淡出动画显示或隐藏瞬态UI或控件。一个例子是在一个应用程序栏中,由于用户交互,可以在其中显示新控件


示例应用程序在显示appbar之前显示/隐藏按钮。在调用ShowOnlyCommand之前,您可能正在应用程序栏上调用show

此问题的临时解决方法是:

在调用
ShowOnlyCommand
HideCommand
之前,将按钮设置为不可见

以下是我目前使用的代码:

/* 
 * @param {WinJS.UI.AppBar} appbar winControl
 * @param {Array} array of appbar buttons to be shown
 */
function showOnlyCommands(appbarControl, buttonsToShow) {
    var toShow = {};
    for (var i = 0; i < buttonsToShow.length; i++) {
        toShow[buttonsToShow[i].id] = true;
    }
    for (var i = 0; i < visibleButtonsList.length; i++) {
        var id = visibleButtonsList[i].id;
        if (!toShow[id]) {
            // set the display property of the buttons to be hidden to "none"               
            var button = document.getElementById(id);
            if (button) {
                button.style.display = 'none';
            }
        }
    }
    // update the visible buttons list
    visibleButtonsList = buttonsToShow;
    // Note that we don't need to set the "display" property back for the buttons, 
    // because WinJS.UI.AppBar.showOnlyCommands would set it back internally
    appbarControl.showOnlyCommands(buttonsToShow);
} 
/*
*@param{WinJS.UI.AppBar}AppBar winControl
*要显示的appbar按钮的@param{Array}数组
*/
功能仅显示命令(appbarControl,按钮显示){
var toShow={};
对于(变量i=0;i
解决此问题的临时方法是:

在调用
ShowOnlyCommand
HideCommand
之前,将按钮设置为不可见

以下是我目前使用的代码:

/* 
 * @param {WinJS.UI.AppBar} appbar winControl
 * @param {Array} array of appbar buttons to be shown
 */
function showOnlyCommands(appbarControl, buttonsToShow) {
    var toShow = {};
    for (var i = 0; i < buttonsToShow.length; i++) {
        toShow[buttonsToShow[i].id] = true;
    }
    for (var i = 0; i < visibleButtonsList.length; i++) {
        var id = visibleButtonsList[i].id;
        if (!toShow[id]) {
            // set the display property of the buttons to be hidden to "none"               
            var button = document.getElementById(id);
            if (button) {
                button.style.display = 'none';
            }
        }
    }
    // update the visible buttons list
    visibleButtonsList = buttonsToShow;
    // Note that we don't need to set the "display" property back for the buttons, 
    // because WinJS.UI.AppBar.showOnlyCommands would set it back internally
    appbarControl.showOnlyCommands(buttonsToShow);
} 
/*
*@param{WinJS.UI.AppBar}AppBar winControl
*要显示的appbar按钮的@param{Array}数组
*/
功能仅显示命令(appbarControl,按钮显示){
var toShow={};
对于(变量i=0;i
非常感谢!我想这正是我的情况。我现在正在度假,所以我不能自己测试。但只要我有机会实现它(2周内),我就会将它标记为正确答案!非常感谢你!嘿@ChrisHerring,我正在尝试你的建议。如果我们没有在显示前调用
上的
showOnlyCommand
,您如何设置右键单击时显示的按钮?您的回答确实帮助我进一步调查,但仍然没有解决我的问题。当appbar打开时,当我调用
ShowOnlyCommand
时,问题仍然会发生。当appbar上的按钮需要更改时,我调用
ShowOnlyCommand
而不是隐藏和显示appbar,flash仍然会出现如果在appbar打开时调用ShowOnlyCommand,您将看到flash,这是我提供的doco链接中提到的预期行为。要在应用程序栏隐藏时进行更改,以避免闪烁。尽量不要使用beforeshow事件,当应用程序中发生某些事情时(例如,首次加载页面时)更改按钮。然后,当调用AppBar时,按钮已经正确设置。因此,在“开始”菜单上,更新按钮不会导致闪烁。我知道Windows在“开始”菜单上做了很多应用程序不支持的事情,这是其中之一吗?非常感谢!我想那是exa