0

I'm working on a Xamarin.Forms project and I've had this error I cant solve for hours now. I'm hoping that someone has experienced a similar problem previously and can share their experience.

I get A Xamarin.Forms.Xaml.XamlParseException was thrown

and this message Position 23:5. Method EditInfoClicked does not have the correct signature

My code looks like this.

XAML Syntax:

    <StackLayout x:Name="_MapStack">
    <Button BackgroundColor="#40A6FF" 
            WidthRequest="100"
            BorderRadius="3" 
            Text="Edit" 
            FontSize="16" 
            TextColor="White"
            Clicked="EditInfoClicked" />

And C# Syntax

    async Task EditInfoClicked(object sender, EventArgs e)
    {
        ProfileDetailViewModel viewModel = new 
        ProfileDetailViewModel (Navigation, user);
        var profileDetailPage = new shared.MyProfilePage()

        {
            BindingContext = viewModel
        };

        await Navigation.PushAsync(profileDetailPage);
    }
SterlinkArcher
  • 673
  • 3
  • 21
  • 36
  • 1
    Return type is Task needs to be void. Check this http://stackoverflow.com/questions/12144077/async-await-when-to-return-a-task-vs-void – Akash Amin Jun 28 '16 at 05:50

1 Answers1

9

You cant have Task for events change to -> events will have to use async void

async void EditInfoClicked(object sender, EventArgs e)
    {
        ProfileDetailViewModel viewModel = new 
        ProfileDetailViewModel (Navigation, user);
        var profileDetailPage = new shared.MyProfilePage()

        {
            BindingContext = viewModel
        };

        await Navigation.PushAsync(profileDetailPage);
    }
Athul Harikumar
  • 2,501
  • 18
  • 16