Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is Xamarin giving error with button Clicked?

Tags:

c#

mobile

xamarin

Basically I am getting this error EventHandler "PressMeButton_Clicked" with correct signature not found in type "login.MainPage" (login)

login is the name of my project and login_Clicked is my clicked event handler

I'm trying to make a simple login page,and on the documentation I've seen various ways of Clicked working but everytime I try to write the method on the xaml.cs file when I compile it keeps giving the error above, if I remove the method it works.

  <Button x:Name="PressMeButton"
                Text="Press Me!"
                Pressed="PressMeButton_Pressed"
                Clicked="PressMeButton_Clicked" />

this is the XAML part you can see on Clicked the name I have for the event and

 private void PressMeButton_Clicked(object sender, EventArgs e)
        {
            (sender as Button).Text = "I was just clicked!";
        }

So I expect to show me a text saying I was clickd but it does not even compile.

like image 465
Erica ross Avatar asked Aug 16 '19 05:08

Erica ross


1 Answers

This is an old question, but I ran into a similar issue. There was no good explanation why it would give the error. It would even happen on an empty handler that the IDE generated itself. I tried cleaning the solution, rebuilding, etc.

I found that there were some stuck build tasks going still. They appeared in the bottom bar that normally shows "Ready". For me, the solution was restarting VS. Once it started back up, and build worked fine.

like image 192
jep Avatar answered Nov 18 '22 17:11

jep