Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the value from the UWP DatePicker control?

Tags:

uwp

I am using a couple of DatePickers in my UWP app and am unsure how to get the current value from it. Is there a simple way to do this?

like image 814
Aellopos Avatar asked Nov 20 '16 09:11

Aellopos


1 Answers

The property you're looking for is Date.

If you've got your DatePicker in your XAML like this

<DatePicker x:Name="DatePicker" />

And want to access the date in the code-behind, you can do that like this

var date = this.DatePicker.Date;

You could also listen to the DateChanged event like this

this.DatePicker.DateChanged += (o, e) =>
        {
            var changedDate = e.NewDate;
        };
like image 119
James Croft Avatar answered Jan 03 '23 07:01

James Croft