WPF Calendar: Boldface specified dates? - wpf

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 for all documents created during that month, which I use to create a list of dates during the month that have documents.
In the Calendar control, I want to boldface those dates that have documents, in the same manner that Outlook boldfaces dates that have appointments.
So, here's my question: How do I boldface a specific date in the Calendar control's month view? Thanks for your help.

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

It turns out that boldfacing is hard-coded in several places, so I changed to date highlighting instead. I wrote a custom control that has a HighlightedDates list; adding a date to the list highlights the date and provides an optional tool tip for the date with whatever content the host app chooses.
I have written a CodeProject article titled Extending the WPF Calendar. The article includes the control and explains how I built it.

Related

How to link DayPicker to existing input element

I'm using react-day-picker DayPicker (not DayPickerInput) and have an existing element I want to use to drive the date popup. I can't figure out how to pre-feed the date from the element to the calendar and highlight the given date. All the other functionality, e.g. capturing the user chosen date and populating the element are working fine. So if my input element has Nov 11, 2019, and I click on it, I want the popup to go to that date and show it as selected. The current behavior is that it shows the current month and date. I've tried to set the selectedDays={this.state.selectedDay}, but that doesn't seem to work. Note that I am new to reactjs, and this could be the gap in my understanding.
Thanks for any suggestions you may have.
Found at least one way to achieve the behavior I was looking for. There is a DayPicker property "initialMonth" that will display the current month. Note that this only needs to be populated only with year and month:
initialMonth = {new Date(selectedDate.getFullYear(), selectedDate.getMonth())}

Is Range selection possible in WPF Date Picker?

My requirement is to have some relative date support in my date picker and I want to select start and end date from wpf date picker. But picker showing single calendar and i couldn't achieve two date selection.i have gone through some sites but couldn't get clear answer.
Is it possible to achieve my requirement in WPF date picker or any custom template available for this?
Thanks,
Indrajeyan.

Show current date in WPF Toolkit Date Time picker

I am using codeplex wpf toolkit and want to show current date at the bottom of calendar same as date time picker of windows form shows, tried various properties but could not find a solution. Please help
If i understand you correctly,you want to show the current selected date in the calender part of the datepicker.For that you want to customize the control template of the Datepciker COntrol.Go through the link below to get started
http://msdn.microsoft.com/en-us/magazine/dd882520.aspx
Edit
To have a Today Button in the calender check the below thread
http://wpf.codeplex.com/discussions/85516?ProjectName=wpf

WPF Datepicker - Bolded Dates

Is there any way to set a series of dates that will be displayed within the DatePicker as bold (or otherwise highlighted)?
=UPDATE=
Apologies, seems I have not explained myself sufficiently. I am looking to get outlook-similar behaviour with the calendar popup on the WPF DatePicker. An example is as follows;
All dates are still selectable and the bolded dates are shown irrespective of any current selection. The purpose of these bolded dates are to aid the user in selecting a date and or to represent items of interest.
Will crossing out work? if so, you could use BlackoutDates (you can have multiple CalendarDateRange )
<DatePicker.BlackoutDates>
<CalendarDateRange Start="2/1/2011" End="2/10/2011"/>
</ DatePicker.BlackoutDates>
or from code
calendar1.BlackoutDates.Add(new CalendarDateRange(
new DateTime(2011, 2, 1),
new DateTime(2010, 2, 10)
));
You can select multiple dates like this
<DatePicker 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">
<DatePicker.SelectedDates>
<sys:DateTime>3/5/2010</sys:DateTime>
<sys:DateTime>3/15/2010</sys:DateTime>
<sys:DateTime>3/25/2010</sys:DateTime>
</DatePicker.SelectedDates>
</DatePicker>
For more info check these links
http://www.c-sharpcorner.com/UploadFile/mahesh/563/
http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-calendar-datepicker-walkthrough.aspx

Date Picker Today Option In WPF

Is there any property , option available in the date picker control so that if user want to select today from any date from current date ?
e.g if user is view current month of last year then he has the option to select current date ?
just see this link and how they are implementing the Today button in the Datepicker WPF Toolkit). This link is from the WPFToolkit discussion forum. May be this will help you.
http://wpf.codeplex.com/Thread/View.aspx?ThreadId=85516
i think there is no option that there is a button directly in the control.
You can use a button outside the control, or something like this to set the current date.
Or you build a custom control....
I just hacked together a simple example. It is VS 2010. www.mbgr.de/CurrentDateWpf.zip.
No warranty at all on this one. Use at your own risk :-)

Resources