Share via

UWP - Open DatePicker programmatically

Lettuce 121 Reputation points
2021-09-08T23:56:10.103+00:00

Hello,

How do I open a DatePicker control in UWP programmatically?

For example, you can open a combo box by setting IsDropDownOpen = true, but no such thing for DatePicker?

Developer technologies | Universal Windows Platform (UWP)
0 comments No comments

Answer accepted by question author

Castorix31 91,876 Reputation points
2021-09-09T02:05:07.323+00:00

You can use a DatePickerFlyout

For example, with a DatePicker datePicker :

var dpflyout = new DatePickerFlyout { Placement = FlyoutPlacementMode.Bottom, Date = datePicker.Date };
dpflyout.DatePicked += (p, ea) => datePicker.Date = p.Date;
dpflyout.ShowAt(datePicker);

Was this answer helpful?

2 people found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Nico Zhu (Shanghai Wicresoft Co,.Ltd.) 12,871 Reputation points
    2021-09-09T02:19:30.66+00:00

    Hello, Welcome to Micorosoft Q&A,

    Open DatePicker programmatically

    I have to say, we can't open datepicker programmatically. because the date select part is not popup like Combobox control, and it is rendered as DatePickerFlyout in the code behind.

    If you do want to select date programmatically, please custom DatePicker with DatePickerFlyout.

    For example

    var flyout = new DatePickerFlyout();  
    await flyout.ShowAtAsync(Picker);  
    

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.