WPF calendar: bold dates?

I am creating a window that uses the WPF calendar to view documents created on the specified dates during the specified month. When the calendar changes month, I look for a database for all documents created during this month, which I use to create a list of dates for the month with documents.

In the calendar control, I want to bold those dates that have documents, in the same way as the offset dates in Outlook that have appointments.

So, here is my question: how do I bold indicate a specific date in the calendar management month view? Thank you for your help.

+5
source share
2 answers

It turns out that the bold font is hard-coded in several places, so I changed the date instead. I wrote a custom control with a list of HighlightedDates; adding a date to the list highlights the date and provides an additional hint for the date with any content that the host application selects.

I wrote a CodeProject article titled Extending a WPF Calendar . The article includes control and explains how I built it.

+2
source

. http://www.c-sharpcorner.com/UploadFile/mahesh/539/Default.aspx " " , , , . , , , , . , .

SelectedDate . , SelectedDates . SelectedDates XAML .

<Calendar Name="MonthlyCalendar" 
    SelectionMode="MultipleRange"  
    DisplayDate="3/5/2010"
    DisplayDateStart="3/1/2010"
    DisplayDateEnd="3/31/2010"
    FirstDayOfWeek="Tuesday"
    IsTodayHighlighted="True" 
    xmlns:sys="clr-namespace:System;assembly=mscorlib" Margin="15,39,88,19">

    <Calendar.SelectedDates>
        <sys:DateTime>3/5/2010</sys:DateTime>
        <sys:DateTime>3/15/2010</sys:DateTime>
        <sys:DateTime>3/25/2010</sys:DateTime>
     </Calendar.SelectedDates>
</Calendar>

, 8, , 5 15 25- - .

SelectedDates WPF .

private void AddSelectedDates()
{
    MonthlyCalendar.SelectedDates.Add(new DateTime(2010, 3, 5));
    MonthlyCalendar.SelectedDates.Add(new DateTime(2010, 3, 15));
    MonthlyCalendar.SelectedDates.Add(new DateTime(2010, 3, 25));
}
+5

All Articles