xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.62k stars 1.87k forks source link

Signature (parameter 1) of EventHandler #5887

Closed FreedomDesi closed 5 years ago

FreedomDesi commented 5 years ago

Hello Sir, Please help me out. When i update the latest Xamarin form version 3.6.0.293080.Come up with error as screenshot.Please solve it. i am waiting... picturemessage_u0uv3hyd q3h

jcmanke commented 5 years ago

Maybe it would help to also post the code that has the error.

samhouts commented 5 years ago

@FreedomDesi Can you please attach a small project that demonstrates this issue? Thanks!

StephaneDelcroix commented 5 years ago

/cc @dieselsoup

DaanTacoSchool commented 5 years ago

This bug occurred in one of my projects as well when i updated from 3.4.xxx75 to 3.6.x I downgraded XF as far as 3.5 but it doesn't seem to go away. This bug occurs both in VS2019 and VS2017. Cannot attach repro project due to tight deadline scheduling.

DaanTacoSchool commented 5 years ago

Issue doesnt occur in xamarin forms 3.4.xx75

samhouts commented 5 years ago

@DaanTacoSchool @FreedomDesi @DieselSoup If you are able to at least post one of the XAML and EventHandler snippets that is causing this issue, that would help us diagnose the issue. Thanks!

akoh-victor commented 5 years ago

Hi I am faced with similar issue after upgrading to xamarin 4.0.0.482894

Signature (parameter 1) of EventHandler "Xceed365m4.Views.People.TeamDetail/_anonXamlCDataTemplate_36.HideShow_directim" doesn't match the event type

here is my xaml code `

                                                </StackLayout.GestureRecognizers>`

code behind private void ViewDetail(object sender, ItemTappedEventArgs e) { //// }

GalaxiaGuy commented 5 years ago

The TappedEvent is a plain EventHandler, not an EventHandler<ItemTappedEventArgs>, which means the signature for view detail should be void ViewDetail(object sender, ItemTappedEventArgs e).

In earlier versions, the XAML compilation was more relaxed about allowing event handlers with the wrong signature, but this was changed (possibly here: https://github.com/xamarin/Xamarin.Forms/pull/3086).

Edit:

Should be: void ViewDetail(object sender, EventArgs e)

akoh-victor commented 5 years ago

@GalaxiaGuy I am using the right event. Tapped to call itemTappedEvent

samhouts commented 5 years ago

@ideal-it-solutions Hi!

@GalaxiaGuy is correct (although he has written the incorrect signature in his comment). You need to use the following signature:

private void ViewDetail(object sender, EventArgs e)
        {

        }

Thanks!

akoh-victor commented 5 years ago

Noted thanks

On Tue, 11 Jun 2019 at 12:32 AM, Samantha Houts notifications@github.com wrote:

@ideal-it-solutions https://github.com/ideal-it-solutions Hi!

@GalaxiaGuy https://github.com/GalaxiaGuy is correct (although he has written the incorrect signature in his comment). You need to use the following signature:

private void ViewDetail(object sender, EventArgs e) {

    }

Thanks!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/xamarin/Xamarin.Forms/issues/5887?email_source=notifications&email_token=AD4XAUEMZASKDSWNDCOAN43PZ3P7RA5CNFSM4HFFSPK2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXLQH3A#issuecomment-500630508, or mute the thread https://github.com/notifications/unsubscribe-auth/AD4XAUEY24LG4PAPRXANYFDPZ3P7RANCNFSM4HFFSPKQ .

-- Regards

GalaxiaGuy commented 5 years ago

Ah, sorry for the confusion.

lywyn commented 5 years ago

According to the source code for the TapGestureRecognizer it uses TappedEventArgs

            EventHandler eventHandler = this.Tapped;
            if (eventHandler != null)
            {
                eventHandler(sender, new TappedEventArgs(this.CommandParameter));
            }            

I have the following xaml/code ;

TapGestureRecognizer Tapped="Item_Tapped" CommandParameter="{Binding .}" />

private void Item_Tapped(object sender, TappedEventArgs e)
{
     var item = (e.Parameter) as ProductModel;
     // cut...
}

This works in VS2017 and Xamarin.Forms 3.2.0.871581.

But when updating project in VS 2019I to use Xamarin Forms 4.0 on a .NET Standard project I get an error when building: "InitializeComponent>_anonXamlCDataTemplate_18.Item_Tapped" doesn't match the event type"

edit

Tried updating XF from 3.2.0.871581 to 3.6.0.34445 and same issue. Here's a screenshot debugging the event in 3.2. It passes a TappedEventArgs and Parameter property passes the model. image