简体   繁体   中英

XAML WP8.1 AppBarButton holding event

I've a following xaml:

<Page.BottomAppBar>
        <CommandBar>
            <AppBarButton Label="- запись -"  Icon="Microphone" Holding="AppBarButton_Holding" PointerPressed="AppBarButton_PointerPressed" PointerReleased="AppBarButton_PointerReleased" />
            <AppBarButton Label="обновить" Icon="Refresh" Click="AppBarButton_Click" />
            <CommandBar.SecondaryCommands>
                <AppBarButton Label="выйти" Click="AppBarButton_Click_1"/>
            </CommandBar.SecondaryCommands>
        </CommandBar>
    </Page.BottomAppBar>

So i'm trying to catch the Holding event (or SOMEHOW understand that button was tapped then released) on the AppBarButton:

private void AppBarButton_Holding(object sender, HoldingRoutedEventArgs e)
        {
            string holdingState = (e.HoldingState == Windows.UI.Input.HoldingState.Started) ? "Holding" : "Held";
            Debug.WriteLine(holdingState);
        }

        private void AppBarButton_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            Debug.WriteLine("pressed!");
        }

        private void AppBarButton_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            Debug.WriteLine("released!");
        }

But I don't get into any of these handler, which is strange to me...

Documentation about this is quiet strange: https://msdn.microsoft.com/library/windows/apps/windows.ui.xaml.controls.appbarbutton.aspx

Holding Occurs when an otherwise unhandled Hold interaction occurs over the hit test area of this element. (Inherited from UIElement)

I found a similar quiestion, but looks like there was no answer on it: WP8.1 AppBarButton holding event

These event handlers exist because AppBarButton inherits from Button. https://msdn.microsoft.com/pl-pl/library/windows/apps/windows.ui.xaml.controls.appbarbutton.aspx

But! I think that microsoft didn't wanted developers to implement holding interactions with app bar buttons. That's just not the right user experience and you should avoid that. I am sure nobody will find it ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM