1

Trying to figure out how to use XLabs ButtonGroup for Xamarin Forms. https://github.com/XLabs/Xamarin-Forms-Labs/wiki/ButtonGroup

I can't find an event handler or any way to set a listener for a click.

The sample code for how to use the button just skips over that detail. https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/Samples/XLabs.Sample/Pages/Controls/ButtonGroupPage.cs

What am I missing?

Thanks, Brad.

BWhite
  • 713
  • 1
  • 7
  • 24

1 Answers1

1

If I remember correctly, I have add these rows

    public delegate void ButtonClickedHandler(int index);
    public event ButtonClickedHandler Clicked;
    protected void OnClicked(int index){
        if (Clicked != null) {
            Clicked (index);            
        }
    }

and modified this method

    /// <summary>
    /// Sets the selected button.
    /// </summary>
    /// <param name="o">The o.</param>
    private void SetSelectedButton(object o)
    {
        if((int)o != SelectedIndex)
            OnClicked ((int)o);
        SelectedIndex = (int)o;
    }
Alessandro Caliaro
  • 5,623
  • 7
  • 27
  • 52