开发者

How do I highlight available days in a Calendar control in WPF?

开发者 https://www.devze.com 2022-12-31 03:40 出处:网络
I wanted to hi开发者_开发知识库ghlight some range of days in a Calendar in WPF, and make any other day in the calendar unavailable. So the user could select only the highlighted range. The problem is,

I wanted to hi开发者_开发知识库ghlight some range of days in a Calendar in WPF, and make any other day in the calendar unavailable. So the user could select only the highlighted range. The problem is, I havent found anything useful to do so yet. The control itself doesnt support data binding at all (although it has Data Context property :-)), which makes it somewhat sloppy.


To make some dates unavailable you can use Calendar.BlackoutDates property. E.g.:

DateTime today = DateTime.Today;
_calendar.BlackoutDates.Add(
    new CalendarDateRange(today.AddDays(-5), today.AddDays(-3)));
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号