SelectedDateChanged Event
Collapse the table of content
Expand the table of content

DatePicker.SelectedDateChanged Event

Occurs when the SelectedDate property is changed.

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

public event EventHandler<SelectionChangedEventArgs> SelectedDateChanged
<sdk:DatePicker SelectedDateChanged="eventhandler"/>

The following code contains an event handler that updates a TextBlock when SelectedDate is changed.

//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] + "!";
        text1.Text = "Changed SelectedDate from " + e.RemovedItems[0] + " to " + e.AddedItems[0] + "!";


Supported in: 5, 4, 3

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

Community Additions

© 2016 Microsoft