سؤال

I've added some UIelements (buttons) programatically to my application interface and i'd like to handle tap events.

I would have done it in my xaml file with

<Button Tap="onTap"/>

How could I do it in C# ? I don't know how i shall use Button.Tap=....

I Have prepared the handler like that :

private void onTouch(object sender, System.Windows.Input.GestureEventArgs e)
        {
            //Cool stuff here
        }

Thank you in advance

هل كانت مفيدة؟

المحلول

You can use += to attach event handler in C# :

MyButton.Tap += onTouch;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top