Xamarin.forms: Signature (parameter 1) of EventHandler

Created on 11 Apr 2019  Â·  13Comments  Â·  Source: xamarin/Xamarin.Forms

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

buildchain unverified bug

All 13 comments

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

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

/cc @dieselsoup

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.

Issue doesnt occur in xamarin forms 3.4.xx75

@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!

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> <TapGestureRecognizer CommandParameter="{Binding .}" Tapped="ViewDetail" /> </StackLayout.GestureRecognizers>

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

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)

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

@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!

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

Ah, sorry for the confusion.

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

Was this page helpful?
0 / 5 - 0 ratings