WPF Datepicker - Bolded Dates - wpf

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

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

select multiple dates by dragging over datepicker dates

I am using Extjs datepicker.
I want to select multiple dates of datepicker by dragging over them.
For that I tried to make calendar dates draggable. I took the reference from here https://docs.sencha.com/extjs/5.1/core_concepts/drag_drop.html and wrote below mentioned code.
var calendarDate = Ext.get('DatePickerSchedule').select('td');
Ext.each(calendarDate.elements, function(el) {
var dd = Ext.create('Ext.dd.DD', el, 'datesDDGroup', {
isTarget: true
});
//Apply the overrides object to the newly created instance of DD
Ext.apply(dd, window.overrides);
});
But it doesn't seems to be working. Please suggest what I am missing.
Check out this Previously Answered Question. There's a fiddle provided that demonstrates how to implement multi-select on a date picker. It doesn't use dragging but it may be a suitable solution for your needs.
EDIT:
So this question really got me interested in how you might go about solving this. So I've had a play around and created custom date picker that extends the ExtJS datepicker but provides drag support for multiple selections using the mouse listeners I had suggested in my comment.
The fiddle can be found here DraggableDatePicker
One improvement you may want to make is to make the component aware of rows and the values within rows, so that when you mouse over a new row all dates on that row (prior to the one currently with the mouseover) are selected. My solution only cares about individual cells that are dragged over.

WPF Calendar: Boldface specified dates?

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.

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 :-)

Date picker doesnt allow edit and no null accepting

I am new to .NET 3.5 , WPF, infragistics and MVVM.
I have two calender controls and button control ( when clicking the button user see a list of events between the date range. We follow MVVM pattern
Start Date(Date Picker) 2. End date(Date Picker) 3. search button
My bussiness gave me some set of rules through which user will be validated.
I have done all validation for the date controls except for the following two:
when editing the date picker (manually with out using calender and typing the date) the change event is never recognized in View Model
Date picker is not allowing null values ( i need my one my date picker to be empty in page load).
If any body wants i can post my code also..
thanks
Divya
There is an ASP.NET version of the datepicker that allows nullable, found here on CodeProject. There was a similar question posted but it was for WinForms here. Ok, the code is for Winforms, maybe you might be able to port it for webforms i.e. asp.net.
Hope this helps,
Best regards,
Tom.

Resources