Compartilhar via


DatePicker.SelectedDateFormat Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the format that is used to display the selected date.

Namespace:  System.Windows.Controls
Assembly:  System.Windows.Controls (in System.Windows.Controls.dll)

Syntax

'Declaration
Public Property SelectedDateFormat As DatePickerFormat
public DatePickerFormat SelectedDateFormat { get; set; }
<sdk:DatePicker SelectedDateFormat="Long"/>
-or-
<sdk:DatePicker SelectedDateFormat="Short"/>

Property Value

Type: System.Windows.Controls.DatePickerFormat
The format that is used to display the selected date. The default is Short.

Exceptions

Exception Condition
ArgumentOutOfRangeException

The specified format is not valid.

Remarks

Dependency property identifier field: SelectedDateFormatProperty

Examples

The following XAML creates two DatePicker controls, one using the default Short format and the other using the Long format. This example is part of a larger example available in the DatePicker overview.

<!-- Two DatePicker controls, one using the default Short date format -->
<!-- and the other using the Long date format. -->
<StackPanel Orientation="Horizontal" >
<TextBlock Width="200" Margin="5" 
           Text="DatePicker with Short date format and Calendar event handlers:" TextWrapping="Wrap" />
<sdk:DatePicker x:Name="dp1" Height="20" Width="200" />
</StackPanel>
<StackPanel Orientation="Horizontal" >
<TextBlock Width="200" Margin="5"
           Text="DatePicker with Long date format and DateSelected event handler:" TextWrapping="Wrap" />
<sdk:DatePicker Height="20" x:Name="dp2" SelectedDateFormat="Long" Width="200"/>
</StackPanel>

Version Information

Silverlight

Supported in: 5, 4, 3

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.