Here is my code in WPF:
XAML:
<StackPanel Width="150">
<DatePicker Name="dpick" FirstDayOfWeek="Monday" SelectedDateFormat="Short"/>
<TextBlock Name="dpText"/>
</StackPanel>
C# Code:
public void dpick_SelectionChanged(object sender, EventArgs e)
{
dpText.Text = dpick.SelectedDate.Value.Year.ToString() + "-" +
dpick.SelectedDate.Value.Month.ToString() + "-" +
dpick.SelectedDate.Value.Day.ToString();
}
dpText.Text is not updated after making a change in date.
Why this is happening.
I have tried with ValueChanged event also.Still no update is happening.
You are not using any of the events on the date picker. Try to add the SelectedDateChanged to the picker, and put your code from dpick_SelectionChanged in the newly created event instead.
Code: