0

是否可以将日历月视图用作日期选择器?制作自定义控件?

4

1 回答 1

0

You can create a XAML page with calender view and can pass the selected date in the parameters along with the previous XAML page from where you landed on the calender view page.

For example, you have a xaml page - MainPage.xaml with button "Select Date". On Tap/Click event of the button use the following code:

private void selectDate_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
   NavigationService.Navigate(new Uri("/dateView.xaml", UriKind.Relative));
}

On dateView.xaml page place your calender view and on calender item click event do the following:

private void calenderItem_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
   var selectedDate = /*calender's selected item*/;
   var lastPage = NavigationService.BackStack.FirstOrDefault();
   string pageName = lastPage.ToString();
   NavigationService.Navigate(new Uri(pageName+"?date="+selectedDate, UriKind.Relative));
}

Then again on MainPage.xaml you could do the following:

protected override void OnNavigatedTo(Microsoft.Phone.Navigation.PhoneNavigationEventArgs e) 
{ 
    base.OnNavigatedTo(e); 
    String date = NavigationContext.QueryString["date"]; 
} 
于 2013-05-15T12:31:01.103 回答