开发者

WP7: Build and use own DatePickerPage

开发者 https://www.devze.com 2023-03-26 10:56 出处:网络
As far as I understand understand the DatePicker control in the WP7 Controls Toolkit, it opens a DatePickerPage to let you select the date for the control.

As far as I understand understand the DatePicker control in the WP7 Controls Toolkit, it opens a DatePickerPage to let you select the date for the control.

I need such a page directly in my app, without the picker control first. Ideally my page would have an additional "today" button, that resets the weels to开发者_开发问答 the current date.

How can I build this? Should I derive from DatePickerPage or DateTimePickerPageBase? How can I call the page (I tried to navigate to the DatePickerPage with NavigationService.Navigate, but I got an NullReferenceException) and get/set the date?


Ok, now I got it. I can manually navigate to the DatePickerPage, but I have to assign the date to the value of the page in the Navigated event:

void dialogFrame_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
    // ...
    IDateTimePickerPage page = e.Content as IDateTimePickerPage;
    if (page != null)
    {
        page.Value = myDate;
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消