![](/img/trans.png)
[英]How can I pass parameters using the "Clicked"-Method on a button in .NET MAUI?
[英]How can I call a method and pass arguments when a button is clicked?
我这段代码:
correctButton.Clicked += (sender, e) =>
{
App.DB.IncrementScore(AS.cfs, AS.phrase);
correctAns++;
AS.pointsCount[(int)AS.cfs]++;
scoreCountLabel.Text = FontAwesome.FAStop.Repeat(correctAns);
Device.StartTimer(TimeSpan.FromSeconds(0.5), () =>
{
switch (AS.cardOrder)
{
case CardOrder.FirstToLast:
AS.orderPhraseIndex++;
AS.phraseIndexList.Add(AS.orderPhraseIndex);
getPhraseFirstToLast();
break;
case CardOrder.Random:
getRandomNumber();
getRandomPhrase();
break;
}
return false;
});
};
我想将运行在方法中的代码移入方法,并同时传递参数。 但是,当单击正确按钮时如何调用该方法?
correctButton.Clicked += correctButtonClicked;
protected void correctButtonClicked(object sender, EventArgs e)
{
// code goes here
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.