[英]How to set OnClick on xlabs.buttongroup for Xamarin?
Trying to figure out how to use XLabs ButtonGroup for Xamarin Forms. 试图弄清楚如何对Xamarin Forms使用XLabs ButtonGroup。 https://github.com/XLabs/Xamarin-Forms-Labs/wiki/ButtonGroup 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 https://github.com/XLabs/Xamarin-Forms-Labs/blob/master/Samples/XLabs.Sample/Pages/Controls/ButtonGroupPage.cs
What am I missing? 我想念什么?
Thanks, Brad. 谢谢,布拉德。
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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.