Articles in this section
Category / Section

How to detect Tab keypress event on SfComboBox in UWP

2 mins read

 

This section explains how to detect Tab Key Press event on SfComboBox by using custom renderer in UWP.

Refer to this Getting started documentation to create a simple SfComboBox sample and configure it.

Step 1: Create a custom combo box class in PCL as like

  public class CustomSfComboBox: SfComboBox
    {
 
    }

 

Step 2: Create Custom renderer for the SfCombobox class in UWP and invoke the KeyDown event to detect the tab press key as like below code snippet

[assembly: ExportRenderer(typeof(CustomSfComboBox), typeof(CustomComboBoxRenderer))]
public class CustomComboBoxRenderer : SfComboBoxRenderer
    {
        protected override void OnElementChanged(ElementChangedEventArgs<Syncfusion.XForms.ComboBox.SfComboBox> e)
        {
            base.OnElementChanged(e);
 
            if (Control != null)
            {
                Control.KeyDown += Control_KeyDown;
            }
        }
 
        private void Control_KeyDown(object sender, Windows.UI.Xaml.Input.KeyRoutedEventArgs e)
        {
 
            if (e.Key == Windows.System.VirtualKey.Tab)
            {
                Xamarin.Forms.Application.Current.MainPage.DisplayAlert("TabKey", "TabKeyPressed", "OK");
            }
        }
    }

 

Step 3: Initialize the CustomSfComboBox in XAML page as like below code snippet

 <customComboBox:CustomSfComboBox />

Output:

Xamarin.Forms SfTabView


You can find the sample in the following link

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied