views:

383

answers:

1

When the calendar control provided in the WPF toolkit (and included in .Net 4) is displayed in "month view", it displays days from the previous and the next month, filling up the entire calendar. When you click on a day of the previous or next month, it will scroll a month backwards or forwards automatically. This behavior is throwing my users off.

Is there any way to prevent this automatic scrolling from happening?

Thanks!

+1  A: 

If you set the DisplayDateStart property to the first day of the month and the DisplayDateEnd property to the last day of the month, those days from other months are not show, and hence cannot be clicked on.

If you can do it in xaml, it would look like this:

 <my:Calendar Margin="50,49,48,43" Name="calendar1"  SelectionMode="MultipleRange"
     DisplayMode="Month" DisplayDateStart="2009-08-01" DisplayDateEnd="2009-08-31"/>

But that would only work if you knew that dates at design time. So you would probably want to set the dates in the code.

        calendar1.DisplayDateStart = new DateTime(2009, 08, 01);
        calendar1.DisplayDateEnd = new DateTime(2009, 08, 31);

Of coarse you would need to provide the first and last day of the particular month.

epotter
Thanks epotter. My calendar still has the next/previous arrows for users to navigate. So it will show dates for any month. Do I need to save the month as I am entering a particular month and set DisplayDateStart/End with the first and last days of the month? How can I do that?Thanks!
Gustavo Cavalcanti
In my experience, with the DisplayDateStart and DisplayDateEnd set within the currently displayed month, the arrows are there, but they don't do anything. On your machine, does the calender move to a different month if the user clicks the arrows?
epotter
You're right. I cannot use the arrows. I assume I programatically reset DisplayDateStart/End in my own arrow buttons. Thanks!
Gustavo Cavalcanti