Export (0) Print
Expand All

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


Silverlight

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

ADD
Show:
© 2014 Microsoft