Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set DatePicker to Today using XAML

I have the following DatePicker control in my project:

<DatePicker x:Name="startDate" SelectedDate="2013-04-03"></DatePicker>

QUESTION:
Is it possible to set the DatePicker.SelectedDate using only XAML?

I know this can be achieved using code-behind.

like image 779
Dom Avatar asked Apr 03 '13 18:04

Dom


1 Answers

Try this...

Add this to xaml refs:

xmlns:sys="clr-namespace:System;assembly=mscorlib"

Then write this:

<DatePicker SelectedDate="{x:Static sys:DateTime.Now}"/>
like image 187
Kevin DiTraglia Avatar answered Oct 16 '22 06:10

Kevin DiTraglia