I am developing WinPhone apps.
<DatePicker x:Name="MyDatePicker" MinYear="2016" MaxYear="2017"/>
The code is not working.
I am able to choose previous years and I am able to choose 2015, 2018, etc. If possible, I would like to disable the months and days in DatePicker itself.
In short, I would like to set minimum and maximum allowed date for calendar so that unwanted dates are disabled in the calendar.
According to documentation, XAML parser doesn't have a conversion logic for converting strings to dates as DateTimeOffset
objects, so MinYear
and MaxYear
property couldn't be set as a XAML attribute string. There are to options to set these properties:
DatePicker
control.View model class:
public DateTimeOffset MinYear
{
get { return new DateTime(2016, 1, 1); }
}
public DateTimeOffset MaxYear
{
get { return new DateTime(2017, 12, 31); }
}
XAML layout:
<DatePicker x:Name="MyDatePicker" MinYear="{Binding MinYear}" MaxYear="{Binding MaxYear}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With