-1
我這個代碼:如何在單擊按鈕時調用方法並傳遞參數?
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時調用該方法?
使一個方法'空隙的MyMethod(對象發件人,EventArgs的)'並將其附加事件:'correctButton.Clicked + =的MyMethod;' – ASh
有https://msdn.microsoft.com/en的讀-us/library/0s21cwxk.aspx。 – mjwills