Reputation: 561
I select a date (not the current date) of a calendar (wpf) by code (C#). Now I want to bring this selected date into view. How can I solve that? All the time the current date is in view.
Any ideas to that? Thank you!
Upvotes: 5
Views: 3212
Reputation: 104702
You have to set the DisplayDate
property as well.
var date = DateTime.Now.AddYears(-10);
cal.SelectedDate = date;
cal.DisplayDate = date;
You may also want to set the SelectionMode property to set the range of dates allowed (CalendarSelectionMode
enumeration).
Upvotes: 5