I am developing window phone 7 application. I am new to the window phone 7 application development. I have added the datepicker control to my application. Now I am able to select the required date whichever I want. I want to submit some information in my application through the Submit button along with the date selected through the datepicker. But I am unaware of how to retrieve the selected date. I am using the following code
<toolki开发者_运维知识库t:DatePicker ValueChanged="DatePicker_ValueChanged" Margin="296,0,0,552" />
Now I have the following function
private void DatePicker_ValueChanged(object sender, DateTimeValueChangedEventArgs e)
{
}
In the above function how should I retrive the date which is selected from the application ? Can you please provide me any code or link through which I can resolve the above issue ?
You should give a name to your DatePicker:
<toolkit:DatePicker Name="MyDate" ValueChanged="DatePicker_ValueChanged" Margin="296,0,0,552" />
Then, in your code-behind:
var date = (DateTime) MyDate.Value;
You should use the DateTimeValueChangedEventArgs
that are provided in the e
argument.
private void DatePicker_ValueChanged(object sender,
DateTimeValueChangedEventArgs e)
{
var date = e.NewDateTime;
}
精彩评论