LaVOZs

The World’s Largest Online Community for Developers

';

I'm having trouble making Button clicks work using Xamarin Forms for Android. My code is just the blank template with a Button and a Click handler added. I'm using Visual Studio 2019 Enterprise. The iOS and UWP projects are present, but disabled.

I've updated all NuGet packages and Android SDKs and Tools to the latest (Xamarin.Forms v4.4.0.991477). I've tried Android 9.0 API 28 and 6.0 API 23.

A breakpoint set in OnButtonClicked is never hit. MainPage itself seems to load fine; no obvious errors or layout problems. No Exceptions are thrown.

I tried downloading a sample project with similar code and running it unmodified -- same problem.

It's acting as though the mouse click / tap on the emulator is being ignored.

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             Title="Home"
             x:Class="Sched.MainPage">
    <ContentPage.Content>
        <StackLayout>
            <Button Text="Button" Clicked="OnButtonClicked" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>
using System;
using System.ComponentModel;
using Xamarin.Forms;

namespace Sched
{
    [DesignTimeVisible(false)]
    public partial class MainPage : ContentPage
    {
        public MainPage()
        {
            InitializeComponent();
        }

        async void OnButtonClicked(object sender, EventArgs e)
        {
            var taskPage = new TaskPage();
            await this.Navigation.PushAsync(taskPage);
        }
    }
}
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:d="http://xamarin.com/schemas/2014/forms/design"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             mc:Ignorable="d"
             Title="Task"
             x:Class="Sched.TaskPage">
    <ContentPage.Content>
        <StackLayout>
            <Label Text="Welcome to Xamarin.Forms!"
                VerticalOptions="CenterAndExpand" 
                HorizontalOptions="CenterAndExpand" />
        </StackLayout>
    </ContentPage.Content>
</ContentPage>