Is there a way to get the Focused or Tapped event on RadComboBox, RadTimePicker and RadDatePicker?

1 Answer 257 Views
ComboBox DatePicker TimePicker
Tasnim
Top achievements
Rank 1
Tasnim asked on 03 Nov 2022, 05:49 AM

I want to perform some operation when the RadComboBox, RadTimePicker and RadDatePicker is focused or tapped. But even if I attach these events, they are not triggered.

Is there a way to do so. Kindly help.

1 Answer, 1 is accepted

Sort by
0
Accepted
Didi
Telerik team
answered on 03 Nov 2022, 07:07 AM

Hi Tasnim,

Let me explain the behavior in details: 

1) RadComboBox focus:

When tapping on the noneditable ComboBox a drop down is opened. The tap gesture is for opening closing the drop-down. When the control is in edit mode, the input receives focus.

In this scenario the Focused event is fired:

        <input:RadComboBox Focused="RadComboBox_Focused" IsEditable="True" Placeholder="combobox"/>
private void RadComboBox_Focused(object sender, FocusEventArgs e)
{
//
}

 

When IsEditable is false the focus event does not fire.

2) Pickers tap

You cannot focus the picker controls, are there isn't an input element in the picker. When tapping on the control, a popup is opened and the ToggleCommand is executed. 

More details about the commands in the picker can be found in this article: https://docs.telerik.com/devtools/xamarin/controls/datepicker/date-picker-commands 

You can add a tap gesture to the Pickers PlaceholderTemplate, still you have to implement the custom logic needed if you do not want to execute the ToggleCommand

In this case the Tap Gesture event is fired:

    <ContentPage.Resources>
        <ResourceDictionary>
            <ControlTemplate x:Key="Picker_PlaceholderView_ControlTemplate">
                <Grid>
                    <Grid.GestureRecognizers>
                        <TapGestureRecognizer Tapped="TapGestureRecognizer_Tapped_1"/>
                    </Grid.GestureRecognizers>
                    <Label Text="{TemplateBinding Placeholder}"
               Style="{TemplateBinding PlaceholderLabelStyle}"
               AutomationId="PickerPlaceholderLabel"/>
                </Grid>
            </ControlTemplate>
        </ResourceDictionary>
    </ContentPage.Resources>
    <StackLayout>
        <input:RadDatePicker MinimumDate="2020,01,1" 
                            MaximumDate="2025,12,31"
                            SpinnerFormat="MMM/dd/yyyy"
                            PlaceholderTemplate="{StaticResource Picker_PlaceholderView_ControlTemplate}">

        </input:RadDatePicker>
    </StackLayout>

 

private void TapGestureRecognizer_Tapped_1(object sender, EventArgs e)
{
// you can execute here the toggle command
}

 

I hope this information was helpful.

Regards,
Didi
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ComboBox DatePicker TimePicker
Asked by
Tasnim
Top achievements
Rank 1
Answers by
Didi
Telerik team
Share this question
or