Reputation: 11
How to set the default text to DatePicker?
I searched in many blogs, all are saying to customize the DatePicker. is it not possible to set the string value to default DatePicker?
Upvotes: 0
Views: 1437
Reputation: 511
I think there are two solutions:
1) Overlay your DatePicker With a Button and Display the default content inside the button. Basicaly you need to implement next behaviour:
2) Use Telerik RadDateSelector control. You must implement the same behaviour but it is much easier:
I use the second approach in my WP8 app and first approach in my WP8.1 app (just because there is no Telerik RadDateSelector for WP8.1 right now).
Hope this helps.
Upvotes: 1
Reputation: 3453
If you need to set a value for date picker , here is what you need to do
private void DatePicker_Loaded(object sender, RoutedEventArgs e)
{
DatePicker picker = sender as DatePicker;
DateTimeOffset newDate = DateTimeOffset.Now;
DateTimeOffset.TryParse("4/17/2013", out newDate);
if (picker != null)
{
picker.Date = newDate;
picker.MinYear = DateTimeOffset.Now;
}
}
Upvotes: 1