4
Vote

Tap event not fired

description

I'm using the bar to bind my buttons to some commands, but one of them has to be bound to a code-behind tap handler.

The command binding works fine, but the Tap event is not fired.
Of course, the Tap event is managed in the xaml.cs file while the command is in a ViewModel.cs class, and this means that I'm changing DataContext in the xaml.cs file in which I have the handler

Here's the code:
<bindableApplicationBar:Bindable.ApplicationBar>
        <bindableApplicationBar:BindableApplicationBar>
            <bindableApplicationBar:BindableApplicationBarButton
                Text="{Binding MainSearchText}"
                IconUri="Assets/AppBar/feature.search.png"
                Command="{Binding NavigateCommand}"/>
            <bindableApplicationBar:BindableApplicationBarButton
                Text="{Binding Path=LocalizedResources.AppBarSettingsText, Source={StaticResource LocalizedStrings}}"
                IconUri="Assets/AppBar/feature.settings.png"
                Tap="SettingsButton_OnTap"/>
            <bindableApplicationBar:BindableApplicationBar.MenuItems>
                <bindableApplicationBar:BindableApplicationBarMenuItem
                    Text="{Binding Path=LocalizedResources.AppBarAboutText, Source={StaticResource LocalizedStrings}}"
                    Command="{Binding AboutCommand}"/>
            </bindableApplicationBar:BindableApplicationBar.MenuItems>
        </bindableApplicationBar:BindableApplicationBar>
    </bindableApplicationBar:Bindable.ApplicationBar>
and here's the handler:
private void SettingsButton_OnTap(object sender, GestureEventArgs e)
        {
            if (_isSettingsOpen)
            {
                CloseSettings();
            }
            else
            {
                OpenSettings();
            }
            Debug.WriteLine("SETTINGS");
        }
Is there anything wrong with my code or I ran into a bug?

comments