Windows 8 打开时如何阻止AppBar捕获触摸活动?

Windows 8 打开时如何阻止AppBar捕获触摸活动?,windows-8,winrt-xaml,Windows 8,Winrt Xaml,我提前道歉,这个很难解释 我有一个GridView,里面有可选择的瓷砖。进行选择时,通过将“等参线”和“IsSticky”设置为true,将显示底部应用栏。这个很好用 但是,当AppBar在第一次选择后出现时,它会捕获任何触摸活动,然后在触摸AppBar外的区域后将其释放,但该触摸手势会被吸收。最后,我触摸屏幕两次以执行第二次选择 在Windows 8的开始屏幕中,您可以依次无缝地选择多个磁贴。显示的底部栏不会干扰后续的触摸手势。但在我的应用程序中,该条捕捉到第一个手势,最后我选择了第二个互动程

我提前道歉,这个很难解释

我有一个GridView,里面有可选择的瓷砖。进行选择时,通过将“等参线”和“IsSticky”设置为true,将显示底部应用栏。这个很好用

但是,当AppBar在第一次选择后出现时,它会捕获任何触摸活动,然后在触摸AppBar外的区域后将其释放,但该触摸手势会被吸收。最后,我触摸屏幕两次以执行第二次选择

在Windows 8的开始屏幕中,您可以依次无缝地选择多个磁贴。显示的底部栏不会干扰后续的触摸手势。但在我的应用程序中,该条捕捉到第一个手势,最后我选择了第二个互动程序两次。这让我的应用程序感觉没有反应

我该如何解决这个问题

要复制此项:

1) 在Visual Studio 2012的Windows应用商店下启动新的“网格应用程序(XAML)”

2) 在GroupedItemsPage.xaml中,向其添加以下xaml:

<Page.BottomAppBar>
    <AppBar>
        <Button Content="X"/>
    </AppBar>
</Page.BottomAppBar>

5) 运行它,注意第一次选择后会出现应用程序栏,但随后您选择第二个互动程序的第二个手势被吸收。

信不信由你,解决方案真的很简单。您必须更改设置
BottomAppBar.IsOpen
BottomAppBar.IsSticky的顺序:

private void ItemGridViewOnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (itemGridView.SelectedItems.Count > 0)
    {
        //this.BottomAppBar.IsOpen = true;
        //this.BottomAppBar.IsSticky = true;

        // must be done in this order for the app bar to work correctly
        this.BottomAppBar.IsSticky = true;
        this.BottomAppBar.IsOpen = true;
    }
    else
    {
        //this.BottomAppBar.IsSticky = false;
        //this.BottomAppBar.IsOpen = false;

        // I have a note in my code to use the following order,
        // but ordering for this doesn't seem to matter.
        this.BottomAppBar.IsOpen = false;
        this.BottomAppBar.IsSticky = false;
    }
}

我不知道为什么排序很重要,但确实如此。

信不信由你,解决方案真的很简单。您必须更改设置
BottomAppBar.IsOpen
BottomAppBar.IsSticky的顺序:

private void ItemGridViewOnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (itemGridView.SelectedItems.Count > 0)
    {
        //this.BottomAppBar.IsOpen = true;
        //this.BottomAppBar.IsSticky = true;

        // must be done in this order for the app bar to work correctly
        this.BottomAppBar.IsSticky = true;
        this.BottomAppBar.IsOpen = true;
    }
    else
    {
        //this.BottomAppBar.IsSticky = false;
        //this.BottomAppBar.IsOpen = false;

        // I have a note in my code to use the following order,
        // but ordering for this doesn't seem to matter.
        this.BottomAppBar.IsOpen = false;
        this.BottomAppBar.IsSticky = false;
    }
}

我不知道为什么排序很重要,但确实如此。

您是否可以发布GridView和应用程序栏xaml?不需要发布这两个元素的子元素。我想看看您在xaml中使用的选项。另外,你可以发布设置应用程序栏的IsOpen和IsSticky字段的代码吗?@chuex I添加了一个示例。使用Visual Studio中的标准网格应用程序非常基本。是否可以发布GridView和应用程序栏xaml?不需要发布这两个元素的子元素。我想看看您在xaml中使用的选项。另外,你可以发布设置应用程序栏的IsOpen和IsSticky字段的代码吗?@chuex I添加了一个示例。使用Visual Studio的标准网格应用程序非常基本。难以置信!我真不好意思!难以置信的我真不好意思!
private void ItemGridViewOnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
    if (itemGridView.SelectedItems.Count > 0)
    {
        //this.BottomAppBar.IsOpen = true;
        //this.BottomAppBar.IsSticky = true;

        // must be done in this order for the app bar to work correctly
        this.BottomAppBar.IsSticky = true;
        this.BottomAppBar.IsOpen = true;
    }
    else
    {
        //this.BottomAppBar.IsSticky = false;
        //this.BottomAppBar.IsOpen = false;

        // I have a note in my code to use the following order,
        // but ordering for this doesn't seem to matter.
        this.BottomAppBar.IsOpen = false;
        this.BottomAppBar.IsSticky = false;
    }
}