WPF Calendar: Boldface specified dates?

前端 未结 2 456
被撕碎了的回忆
被撕碎了的回忆 2021-01-12 10:49

I am creating a window that uses a WPF calendar to browse documents created on specified dates during the month shown. When the calendar changes month, I search a database f

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-12 11:20

    This may help. http://www.c-sharpcorner.com/UploadFile/mahesh/539/Default.aspx The "Selected Date and Selected Dates" area will show you how to select them, and further down it can show you how to format your calendar. That is, if you're using the same calendar which I hope you are. Hope this helps.

    Selected Date and Selected Dates

    SelectedDate property represents the current selected date. If multiple date selection is true, then SelectedDates property represents all selected dates in a Calendar. The following code snippet sets the SelectedDates in XAML at design-time.

    
    
        
            3/5/2010
            3/15/2010
            3/25/2010
         
    
    

    The selected dates in a Calendar looks like Figure 8 where you can see March 5th, 15th, and 25th have a light blue background and represents the selected dates.

    The following code snippet sets the SelectedDates property in WPF at run-time.

    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));
    }
    

提交回复
热议问题