0
votes
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        datepicker.DataContext = e.Parameter;
        time.DataContext = e.Parameter;
    }

    <DatePicker Name="datepicker" Header="Date" Date="{Binding Date}"/>
    <TimePicker Name="time" Header="Time" Time="{Binding Time}"/>

I have a listbox of entries of type Reminder on a page. I select one of the items and navigate to the next page, passing the ListBox.SelectedItem. I want to be able to bind the date passed from the previous page to the DatePicker on the current page. I am able to bind the time to the TimePicker, but not the date to the DatePicker.

Any suggestions on how I can do this?

1
Please show your work as a text, not image. - Soner Gönül
@Soner - Edited to show code as text instead of image. - PhoenixFirenzy
Are you talking about Reminder class? Or is it some custom class you have created? - Abhishek
It is a custom class I have created called Reminder - PhoenixFirenzy
I'm guessing your Date property is of type DateTime. On the other hand, the DatePicker.Date property is of type DateTimeOffset. So you'll probably need to convert it to DateTimeOffset type. I could be more sure if I could take a look at your Reminder class. - Abhishek

1 Answers

2
votes

Converted Date to DateTimeOffset and now it works correctly.