Xamarin.Forms GestureRecognizers添加简写?

时间:2016-03-31 16:08:44

标签: lambda xamarin uitapgesturerecognizer xamarin-forms

以下代码可以进一步简化吗?

var onLogoutTap = new TapGestureRecognizer();
onLogoutTap.Tapped += (object sender, EventArgs e) => {
    MessagingCenter.Send(this, "Logout");
};
logoutImage.GestureRecognizers.Add(onLogoutTap);

.Tapped...部分能否以某种方式直接传递到TapGestureRecognizer()

1 个答案:

答案 0 :(得分:3)

是。 var swiper = new Swiper('.swiper-container', { slidesPerView: 'auto', freeMode: true, nextButton: '.swiper-button-next', prevButton: '.swiper-button-prev', }); 有多个constructors,您可以在其中传递回调。

TapGestureRecognizer