按钮没有正确的签名 xamarin [英] Button does not have the correct signature xamarin
本文介绍了按钮没有正确的签名 xamarin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理一个 Xamarin.Forms 项目,但我遇到了这个错误,我几个小时都无法解决.我希望有人以前遇到过类似的问题并可以分享他们的经验.
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.
我得到 一个 Xamarin.Forms.Xaml.XamlParseException 被抛出
和这个消息 位置 23:5.方法 EditInfoClicked 没有正确的签名
我的代码看起来像这样.
My code looks like this.
XAML 语法:
<StackLayout x:Name="_MapStack">
<Button BackgroundColor="#40A6FF"
WidthRequest="100"
BorderRadius="3"
Text="Edit"
FontSize="16"
TextColor="White"
Clicked="EditInfoClicked" />
和 C# 语法
async Task EditInfoClicked(object sender, EventArgs e)
{
ProfileDetailViewModel viewModel = new
ProfileDetailViewModel (Navigation, user);
var profileDetailPage = new shared.MyProfilePage()
{
BindingContext = viewModel
};
await Navigation.PushAsync(profileDetailPage);
}
推荐答案
您不能将事件的任务更改为 -> 事件必须使用 async void
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);
}
这篇关于按钮没有正确的签名 xamarin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文