DatePicker.SelectedDateChanged Event
Microsoft Silverlight will reach end of support after October 2021. Learn more.
Occurs when the SelectedDate property is changed.
Namespace: System.Windows.Controls
Assembly: System.Windows.Controls (in System.Windows.Controls.dll)
Syntax
'Declaration
Public Event SelectedDateChanged As EventHandler(Of SelectionChangedEventArgs)
public event EventHandler<SelectionChangedEventArgs> SelectedDateChanged
<sdk:DatePicker SelectedDateChanged="eventhandler"/>
Examples
The following code contains an event handler that updates a TextBlock when SelectedDate is changed.
'Updates a TextBlock with information from the SelectedDateChanged event.
Private Sub dp2_SelectedDateChanged(ByVal sender As Object, ByVal e As SelectionChangedEventArgs) Handles dp2.SelectedDateChanged
'RemovedItems will be null if this is the first time a date was selected.
If e.RemovedItems Is Nothing OrElse e.RemovedItems.Count = 0 Then
text1.Text = "Changed SelectedDate from nothing to " + e.AddedItems(0) + "!"
Else
text1.Text = "Changed SelectedDate from " + e.RemovedItems(0) + " to " + e.AddedItems(0) + "!"
End If
End Sub
//Updates a TextBlock with information from the SelectedDateChanged event.
void dp2_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
{
//RemovedItems will be null if this is the first time a date was selected.
if (e.RemovedItems == null || e.RemovedItems.Count == 0)
{
text1.Text = "Changed SelectedDate from null to " + e.AddedItems[0] + "!";
}
else
{
text1.Text = "Changed SelectedDate from " + e.RemovedItems[0] + " to " + e.AddedItems[0] + "!";
}
}
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.