Click here to Skip to main content
15,914,500 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hai All,

in my wpf application i have to setup a date picker calenders which show all dates except some to be disable or black out.
How do i set only some dates enable? all except need to blackout or disable..

thank you.
Posted
Comments
WiganLatics 19-Jan-15 8:38am    
Can't you do something like this?

myDatePicker.SelectableDateStart = DateTime.Now; // Assuming you want today to be the first selectable day
Indukanth 19-Jan-15 9:08am    
Hi WiganLatics, actually i need to show a list of dates only enable..
ie, for example 21/01/2014,22/01/2014,24/01/2014,25/01/2014 these dates only enable while on my datepicker selection all other dates will be disable or blackout..

1 solution

Hi,

Look here:
http://msdn.microsoft.com/en-us/library/system.windows.controls.calendar%28v=vs.110%29.aspx[^]

Property: BlackoutDates

XML
<StackPanel Orientation="Horizontal">

  <!-- Create a Calendar that displays 1/10/2009
             through 4/18/2009. -->
  <Calendar Margin="20" 
            SelectedDate="2/15/2009"
            DisplayDate="3/15/2009"
            DisplayDateStart="1/10/2009"
            DisplayDateEnd="4/18/2009"/>

  <!-- Create a Calendar that displays dates through
       Januarary 31, 2009 and has dates that are not selectable. -->
  <Calendar Margin="20" SelectionMode="MultipleRange"  
            IsTodayHighlighted="false" 
            DisplayDate="1/1/2009"
            DisplayDateEnd="1/31/2009"
            xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <Calendar.BlackoutDates>
      <CalendarDateRange Start="1/2/2009" End="1/4/2009"/>
      <CalendarDateRange Start="1/9/2009" End="1/9/2009"/>
      <CalendarDateRange Start="1/16/2009" End="1/16/2009"/>
      <CalendarDateRange Start="1/23/2009" End="1/25/2009"/>
      <CalendarDateRange Start="1/30/2009" End="1/30/2009"/>
    </Calendar.BlackoutDates>

    <Calendar.SelectedDates>
      <sys:DateTime>1/5/2009</sys:DateTime>
      <sys:DateTime>1/12/2009</sys:DateTime>
      <sys:DateTime>1/14/2009</sys:DateTime>
      <sys:DateTime>1/13/2009</sys:DateTime>
      <sys:DateTime>1/15/2009</sys:DateTime>
      <sys:DateTime>1/27/2009</sys:DateTime>
      <sys:DateTime>4/2/2009</sys:DateTime>
    </Calendar.SelectedDates>
  </Calendar>

</StackPanel>


Please, see image:
http://snap.ashampoo.com/uploads/2015-01-19/jUIK5UhB.png
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900