Export (0) Print
Expand All

Calendar.SelectedDate Property

Gets or sets the currently selected date.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

member SelectedDate : Nullable<DateTime> with get, set
<Calendar SelectedDate="dateTimeString"/>

XAML Values

dateTimeString

A date that is in one of the formats that are listed in the DateTime XAML Syntax topic.

Property Value

Type: System.Nullable(DateTime)
The date currently selected. The default is a null reference (Nothing in Visual Basic).

Identifier field

SelectedDateProperty

Metadata properties set to true

BindsTwoWayByDefault

Use this property when SelectionMode is set to SingleDate. In other modes, this property will always be the first date in SelectedDates.

ExceptionCondition
ArgumentOutOfRangeException

The specified date is outside the range specified by DisplayDateStart and DisplayDateEnd

-or-

The specified date is in the BlackoutDates collection.

InvalidOperationException

If set to anything other than a null reference (Nothing in Visual Basic) when SelectionMode is set to None.

The following example creates a Calendar with a particular range of displayable dates, and sets the currently selected and displayed date.

No code example is currently available or this language may not be supported.
<!-- Create a Calendar that displays 1/10/2009
           through 4/18/2009. -->
<Calendar Margin="20" 
          SelectedDate="2/15/2009"
          DisplayDate="3/15/2009"
          DisplayDateStart="1/10/2009"
          DisplayDateEnd="4/18/2009"/>

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4

.NET Framework Client Profile

Supported in: 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft