3.0 KiB
layout | title | description | platform | control | documentation |
---|---|---|---|---|---|
post | Events in Xamarin Picker control | Syncfusion | Learn here all about Events support in Syncfusion Xamarin Picker (SfPicker) control, its elements and more. | xamarin | SfPicker | ug |
Events in Xamarin Picker (SfPicker)
Three events have been used for a picker when it is in the Dialog
mode. They are,
- Opened
- Closing
- Closed
Opened event
The Opened
event occurs when the picker is opened.
Closing event
The Closing
event raises when the picker gets closing. You can stop the picker close action by setting the e.cancel
to true.
Closed event
The Closed
event was raised after the picker is closed.
{% tabs %}
{% highlight xaml %}
<ContentPage.Content>
<syncfusion:SfPicker Opened="picker_Opened" Closed="picker_Closed" Closing="picker_Closing">
...
</syncfusion:SfPicker>
</ContentPage.Content>
{% endhighlight %}
{% highlight C# %}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
namespace PickerClosingEventSample
{
public partial class MainPage : ContentPage
{
SfPicker picker = new SfPicker();
public MainPage()
{
InitializeComponent();
picker.Opened += picker_Opened;
picker.Closing += picker_Closing;
picker.Closed += picker_Closed;
}
private void picker_Opened(object sender, EventArgs e)
{
// handle the open action
}
private void Picker_Closing(object sender, Syncfusion.XForms.Core.CancelEventArgs e)
{
// stop the close action by setting the `e.cancel` to true.
}
private void picker_Closed(object sender, EventArgs e)
{
// hit after the picker is closed.
}
}
} {% endhighlight %}
{% endtabs %}
N> View sample in GitHub
N> You can refer to our Xamarin Picker feature tour page for its groundbreaking feature representations. You can also explore our Xamarin.Forms Picker example to knows the functionalities of each feature.