Class GlobalCalendar
Represents a control that enables a user to select a date by using a visual calendar display.
Inherited Members
Namespace: System.Windows.Controls
Assembly: OpenSilver.Controls.Toolkit.dll
Syntax
[TemplatePart(Name = "Root", Type = typeof(Panel))]
[TemplatePart(Name = "CalendarItem", Type = typeof(GlobalCalendarItem))]
[StyleTypedProperty(Property = "CalendarButtonStyle", StyleTargetType = typeof(GlobalCalendarButton))]
[StyleTypedProperty(Property = "CalendarDayButtonStyle", StyleTargetType = typeof(GlobalCalendarDayButton))]
[StyleTypedProperty(Property = "CalendarItemStyle", StyleTargetType = typeof(GlobalCalendarItem))]
public class GlobalCalendar : Control, IControl, IFrameworkElement, IUIElement, IDependencyObject
Remarks
A GlobalCalendar control can be used on its own, or as a drop-down part of a DatePicker control. For more information, see DatePicker. A GlobalCalendar displays either the days of a month, the months of a year, or the years of a decade, depending on the value of the DisplayMode property. When displaying the days of a month, the user can select a date, a range of dates, or multiple ranges of dates. The kinds of selections that are allowed are controlled by the SelectionMode property.
The range of dates displayed is governed by the DisplayDateStart and DisplayDateEnd properties. If DisplayMode is Year or Decade, only months or years that contain displayable dates will be displayed. Setting the displayable range to a range that does not include the current DisplayDate will throw an ArgumentOutOfRangeException.
The BlackoutDates property can be used to specify dates that cannot be selected. These dates will be displayed as dimmed and disabled.
By default, Today is highlighted. This can be disabled by setting IsTodayHighlighted to false.
The GlobalCalendar control provides basic navigation using either the mouse or keyboard. The following table summarizes keyboard navigation.
Key Combination DisplayMode Action
ARROW Any Change focused date, unselect
all selected dates, and select
new focused date.
SHIFT+ARROW Any If SelectionMode is not set to
SingleDate or None begin
selecting a range of dates.
CTRL+UP ARROW Any Switch to the next larger
DisplayMode. If DisplayMode is
already Decade, no action.
CTRL+DOWN ARROW Any Switch to the next smaller
DisplayMode. If DisplayMode is
already Month, no action.
SPACEBAR Month Select focused date.
SPACEBAR Year or Decade Switch DisplayMode to the Month
or Year represented by focused
item.
CTRL+HOME Any Switch DisplayMode to Month,
show today's date, and try to
select the date if allowed.
XAML Usage for Classes Derived from GlobalCalendar If you define a class that derives from GlobalCalendar, the class can be used as an object element in XAML, and all of the inherited properties and events that show a XAML usage in the reference for the GlobalCalendar members can have the same XAML usage for the derived class. However, the object element itself must have a different prefix mapping than the controls: mapping shown in the usages, because the derived class comes from an assembly and namespace that you create and define. You must define your own prefix mapping to an XML namespace to use the class as an object element in XAML.
Constructors
| Improve this Doc View SourceGlobalCalendar()
Initializes a new instance of the GlobalCalendar class.
Declaration
public GlobalCalendar()
Fields
| Improve this Doc View SourceCalendarButtonStyleProperty
Identifies the CalendarButtonStyle dependency property.
Declaration
public static readonly DependencyProperty CalendarButtonStyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the CalendarButtonStyle dependency property. |
CalendarDayButtonStyleProperty
Identifies the CalendarDayButtonStyle dependency property.
Declaration
public static readonly DependencyProperty CalendarDayButtonStyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
Remarks
The identifier for the CalendarDayButtonStyle dependency property.
CalendarDayButtonStyleSelectorProperty
Identifies the CalendarDayButtonStyleSelector dependency property.
Declaration
public static readonly DependencyProperty CalendarDayButtonStyleSelectorProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
CalendarInfoProperty
Identifies the CalendarInfo dependency property.
Declaration
public static readonly DependencyProperty CalendarInfoProperty
Field Value
Type | Description |
---|---|
DependencyProperty |
CalendarItemStyleProperty
Identifies the CalendarItemStyle dependency property.
Declaration
public static readonly DependencyProperty CalendarItemStyleProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the CalendarItemStyle dependency property. |
DisplayDateEndProperty
Identifies the DisplayDateEnd dependency property.
Declaration
public static readonly DependencyProperty DisplayDateEndProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the DisplayDateEnd dependency property. |
DisplayDateProperty
Identifies the DisplayDate dependency property.
Declaration
public static readonly DependencyProperty DisplayDateProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the DisplayDate dependency property. |
DisplayDateStartProperty
Identifies the DisplayDateStart dependency property.
Declaration
public static readonly DependencyProperty DisplayDateStartProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the DisplayDateStart dependency property. |
DisplayModeProperty
Identifies the DisplayMode dependency property.
Declaration
public static readonly DependencyProperty DisplayModeProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the DisplayMode dependency property. |
FirstDayOfWeekProperty
Identifies the FirstDayOfWeek dependency property.
Declaration
public static readonly DependencyProperty FirstDayOfWeekProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the FirstDayOfWeek dependency property. |
IsTodayHighlightedProperty
Identifies the IsTodayHighlighted dependency property.
Declaration
public static readonly DependencyProperty IsTodayHighlightedProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the IsTodayHighlighted dependency property. |
SelectedDateProperty
Identifies the SelectedDate dependency property.
Declaration
public static readonly DependencyProperty SelectedDateProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the SelectedDate dependency property. |
SelectionModeProperty
Identifies the SelectionMode dependency property.
Declaration
public static readonly DependencyProperty SelectionModeProperty
Field Value
Type | Description |
---|---|
DependencyProperty | The identifier for the SelectionMode dependency property. |
Properties
| Improve this Doc View SourceBlackoutDates
Gets a collection of dates that are marked as not selectable.
Declaration
public GlobalCalendarBlackoutDatesCollection BlackoutDates { get; }
Property Value
Type | Description |
---|---|
GlobalCalendarBlackoutDatesCollection | A collection of dates that cannot be selected. The default value is an empty collection. |
Remarks
Dates in this collection will appear as disabled on the calendar.
To make all past dates not selectable, you can use the AddDatesInPast method provided by the collection returned by this property.
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Adding a date to this collection when it is already selected or adding a date outside the range specified by DisplayDateStart and DisplayDateEnd. |
CalendarButtonStyle
Gets or sets the Style associated with the control's internal GlobalCalendarButton object.
Declaration
public Style CalendarButtonStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The current style of the GlobalCalendarButton object. |
CalendarDayButtonStyle
Gets or sets the Style associated with the control's internal GlobalCalendarDayButton object.
Declaration
public Style CalendarDayButtonStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The current style of the GlobalCalendarDayButton object. |
CalendarDayButtonStyleSelector
Gets or sets a CalendarDayButtonStyleSelector that enables an application writer to provide custom style-selection logic for the day buttons.
Declaration
public CalendarDayButtonStyleSelector CalendarDayButtonStyleSelector { get; set; }
Property Value
Type | Description |
---|---|
CalendarDayButtonStyleSelector |
CalendarInfo
Gets or sets the CalendarInfo that provides globalized date operations.
Declaration
public CalendarInfo CalendarInfo { get; set; }
Property Value
Type | Description |
---|---|
CalendarInfo |
CalendarItemStyle
Gets or sets the Style associated with the control's internal GlobalCalendarItem object.
Declaration
public Style CalendarItemStyle { get; set; }
Property Value
Type | Description |
---|---|
Style | The current style of the GlobalCalendarItem object. |
DisplayDate
Gets or sets the date to display.
Declaration
[TypeConverter(typeof(DateTimeTypeConverter))]
public DateTime DisplayDate { get; set; }
Property Value
Type | Description |
---|---|
System.DateTime | The date to display. |
Remarks
This property allows the developer to specify a date to display. If this property is a null reference (Nothing in Visual Basic), SelectedDate is displayed. If SelectedDate is also a null reference (Nothing in Visual Basic), Today is displayed. The default is Today.
To set this property in XAML, use a date specified in the format yyyy/mm/dd. The mm and dd components must always consist of two characters, with a leading zero if necessary. For instance, the month of May should be specified as 05.
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The given date is not in the range specified by DisplayDateStart and DisplayDateEnd. |
DisplayDateEnd
Gets or sets the last date to be displayed.
Declaration
[TypeConverter(typeof(DateTimeTypeConverter))]
public DateTime? DisplayDateEnd { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | The last date to display. |
Remarks
To set this property in XAML, use a date specified in the format yyyy/mm/dd. The mm and dd components must always consist of two characters, with a leading zero if necessary. For instance, the month of May should be specified as 05.
DisplayDateStart
Gets or sets the first date to be displayed.
Declaration
[TypeConverter(typeof(DateTimeTypeConverter))]
public DateTime? DisplayDateStart { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | The first date to display. |
Remarks
To set this property in XAML, use a date specified in the format yyyy/mm/dd. The mm and dd components must always consist of two characters, with a leading zero if necessary. For instance, the month of May should be specified as 05.
DisplayMode
Gets or sets a value indicating whether the calendar is displayed in months, years, or decades.
Declaration
public CalendarMode DisplayMode { get; set; }
Property Value
Type | Description |
---|---|
CalendarMode | A value indicating what length of time the GlobalCalendar should display. |
FirstDayOfWeek
Gets or sets the day that is considered the beginning of the week.
Declaration
public DayOfWeek FirstDayOfWeek { get; set; }
Property Value
Type | Description |
---|---|
System.DayOfWeek | A System.DayOfWeek representing the beginning of the week. The default is System.DayOfWeek.Sunday. |
IsTodayHighlighted
Gets or sets a value indicating whether the current date is highlighted.
Declaration
public bool IsTodayHighlighted { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | True if the current date is highlighted; otherwise, false. The default is true. |
SelectedDate
Gets or sets the currently selected date.
Declaration
[TypeConverter(typeof(DateTimeTypeConverter))]
public DateTime? SelectedDate { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> | The date currently selected. The default is null. |
Remarks
Use this property when SelectionMode is set to SingleDate. In other modes, this property will always be the first date in SelectedDates.
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | The given date is outside the range specified by DisplayDateStart and DisplayDateEnd -or- The given date is in the BlackoutDates collection. |
System.InvalidOperationException | If set to anything other than null when SelectionMode is set to None. |
SelectedDates
Gets a collection of selected dates.
Declaration
public GlobalSelectedDatesCollection SelectedDates { get; }
Property Value
Type | Description |
---|---|
GlobalSelectedDatesCollection | A GlobalSelectedDatesCollection object that contains the currently selected dates. The default is an empty collection. |
Remarks
Dates can be added to the collection either individually or in a range using the AddRange method. Depending on the value of the SelectionMode property, adding a date or range to the collection may cause it to be cleared. The following table lists how CalendarSelectionMode affects the SelectedDates property.
CalendarSelectionMode Description None No selections are allowed. SelectedDate cannot be set and no values can be added to SelectedDates.
SingleDate Only a single date can be selected, either by setting SelectedDate or the first value in SelectedDates. AddRange cannot be used.
SingleRange A single range of dates can be selected. Setting SelectedDate, adding a date individually to SelectedDates, or using AddRange will clear all previous values from SelectedDates. MultipleRange Multiple non-contiguous ranges of dates can be selected. Adding a date individually to SelectedDates or using AddRange will not clear SelectedDates. Setting SelectedDate will still clear SelectedDates, but additional dates or range can then be added. Adding a range that includes some dates that are already selected or overlaps with another range results in the union of the ranges and does not cause an exception.
SelectionMode
Gets or sets a value that indicates what kind of selections are allowed.
Declaration
public CalendarSelectionMode SelectionMode { get; set; }
Property Value
Type | Description |
---|---|
CalendarSelectionMode | A value that indicates the current selection mode. The default is SingleDate. |
Remarks
This property determines whether the GlobalCalendar allows no selection, selection of a single date, or selection of multiple dates. The selection mode is specified with the CalendarSelectionMode enumeration.
When this property is changed, all selected dates will be cleared.
Methods
| Improve this Doc View SourceOnApplyTemplate()
Builds the visual tree for the GlobalCalendar when a new template is applied.
Declaration
public override void OnApplyTemplate()
Overrides
| Improve this Doc View SourceOnCreateAutomationPeer()
Returns a GlobalCalendarAutomationPeer for use by the Silverlight automation infrastructure.
Declaration
protected override AutomationPeer OnCreateAutomationPeer()
Returns
Type | Description |
---|---|
AutomationPeer | A GlobalCalendarAutomationPeer for the GlobalCalendar object. |
Overrides
Remarks
This method creates a new GlobalCalendarAutomationPeer instance if one has not been created for the control instance; otherwise, it returns the GlobalCalendarAutomationPeer previously created.
Classes that participate in the Silverlight automation infrastructure must implement this method to return a class-specific derived class of AutomationPeer that reports information for automation behavior.
OnMouseWheel(MouseWheelEventArgs)
Mouse wheel handler simulates (Ctrl+)PageUp/Down.
Declaration
protected override void OnMouseWheel(MouseWheelEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
MouseWheelEventArgs | e | Event arguments. |
Overrides
| Improve this Doc View SourceToString()
Provides a text representation of the selected date.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A text representation of the selected date, or an empty string if SelectedDate is null. |
Overrides
Events
| Improve this Doc View SourceDisplayDateChanged
Occurs when the DisplayDate property is changed.
Declaration
public event EventHandler<GlobalCalendarDateChangedEventArgs> DisplayDateChanged
Event Type
Type | Description |
---|---|
System.EventHandler<GlobalCalendarDateChangedEventArgs> |
Remarks
This event occurs after DisplayDate is assigned its new value.
DisplayModeChanged
Occurs when the DisplayMode property is changed.
Declaration
public event EventHandler<CalendarModeChangedEventArgs> DisplayModeChanged
Event Type
Type | Description |
---|---|
System.EventHandler<CalendarModeChangedEventArgs> |
SelectedDatesChanged
Occurs when the collection returned by the SelectedDates property is changed.
Declaration
public event EventHandler<SelectionChangedEventArgs> SelectedDatesChanged
Event Type
Type | Description |
---|---|
System.EventHandler<SelectionChangedEventArgs> |