0
votes

In XAMARIN FORMS ButtonRenderer only provide two methods which i can override: OnElementChanged and OnElementPropertyChanged. Which method do I want to override to handle button clicks?

1
I am pretty sure that this is what OP is asking. Please forgive me if I am wrong.Mad Physicist

1 Answers

2
votes

You have a reference to the button in your Renderer (search for the proeprty Control). Just add the click-event/listener/command for this Control (but be carefull, it may be that the Control is NULL, depending on your renderer implementation).

Quick code sample for ios (depends on your renderer):

protected override void OnElementChanged(ElementChangedEventArgs<MyButtonRenderer> e)
{
    var mybutton = Control as UIButton;
    mybutton.TouchUpInside += (s, args) => { /* your logic */};
}

For android you can find a sample on this page.