BINAY THAPA MAGAR
BINAY THAPA MAGAR

Reputation: 4341

disable past date in datepicker wpf?

How can i disable past date in date picker?I am using ModernUI for my desktop application

<DatePicker Grid.Column="0" Name="datepicker"  SelectedDate="{x:Static sys:DateTime.Now}" />

Upvotes: 1

Views: 1679

Answers (2)

BINAY THAPA MAGAR
BINAY THAPA MAGAR

Reputation: 4341

Thanks @GauravKP for your help. I used xmlns:sys="clr-namespace:System;assembly=mscorlib" for getting Current date as

 SelectedDate="{x:Static sys:DateTime.Now}"

and using DisplayDateStart="{x:Static sys:DateTime.Now}" to hide previous date.

<DatePicker Grid.Column="0" Name="datepicker" DisplayDateStart="{x:Static sys:DateTime.Now}" SelectedDate="{x:Static sys:DateTime.Now}" ></DatePicker>

Upvotes: 1

Kemal G&#252;ler
Kemal G&#252;ler

Reputation: 614

at codebehind you can define display date like this

datepicker.DisplayDateStart = DateTime.Now;

Upvotes: 0

Related Questions