This is a migrated thread and some comments may be shown as answers.

Pop date picker from another button (focus)

3 Answers 984 Views
DatePicker
This is a migrated thread and some comments may be shown as answers.
E
Top achievements
Rank 1
E asked on 09 Oct 2020, 06:58 PM

I have a RadDatePicker: <telerikInput:RadDatePicker x:Name="MainDatePicker"></telerikInput:RadDatePicker>

I have another button on the page that i want to use to pop the date selection. I would assume like other controls, i could just do: MainDatePicker.Focus(). This returns false, and doesn't actually pop the calendar selection.

If I use a standard DatePicker, it pops the calendar selection. Any ideas?

3 Answers, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 13 Oct 2020, 07:54 AM

Hello Anthony,

If I understood correctly you want to open the DatePicker Popup from another button, not tapping on the picker. If this is the scenario you can visualize the Date Picker popup using the control's toggle command. For more details about Date Picker commands - check the following link form our documentation: https://docs.telerik.com/devtools/xamarin/controls/datepicker/date-picker-commands 

Here is an example:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="100"/>
    </Grid.RowDefinitions>

    <input:RadButton Clicked="RadButton_Clicked" Text="Focus date picker"/>

    <input:RadDatePicker x:Name="datePicker" Grid.Row="1"/>
</Grid>

executing the ToggleCommand in the Button Clicked event:

 

private void RadButton_Clicked(object sender, EventArgs e)
{
    Device.StartTimer(TimeSpan.FromMilliseconds(500), () => {
        this.datePicker.ToggleCommand.Execute(null);

        return false;
    });
}

I hope the provided information was helpful.

Regards,
Didi
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
Didi
Telerik team
answered on 13 Oct 2020, 08:17 AM

Hi Anthony,

Please review the link I have sent in my previous reply about the Date Picker Commands. It contains a different solution for achieving the scenario. 

    <Button Text="Toggle Command" Command="{Binding Source={x:Reference datePicker}, Path=ToggleCommand}"/>

It is up to you which approach to use.

Regards,
Didi
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
E
Top achievements
Rank 1
answered on 13 Oct 2020, 01:41 PM
Thank you. That works perfectly. 
Tags
DatePicker
Asked by
E
Top achievements
Rank 1
Answers by
Didi
Telerik team
E
Top achievements
Rank 1
Share this question
or