diff --git a/Samples/Appointments/cs/Package.appxmanifest b/Samples/Appointments/cs/Package.appxmanifest index 2b949dd354..3ad469f87e 100644 --- a/Samples/Appointments/cs/Package.appxmanifest +++ b/Samples/Appointments/cs/Package.appxmanifest @@ -27,5 +27,6 @@ + \ No newline at end of file diff --git a/Samples/Appointments/cs/Scenario5_Show.xaml.cs b/Samples/Appointments/cs/Scenario5_Show.xaml.cs index b1d4042362..96dbca12a1 100644 --- a/Samples/Appointments/cs/Scenario5_Show.xaml.cs +++ b/Samples/Appointments/cs/Scenario5_Show.xaml.cs @@ -13,6 +13,10 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; using System; +using Windows.ApplicationModel.Appointments; +using System.Linq; +using System.Collections.ObjectModel; +using System.Threading.Tasks; namespace SDKTemplate { @@ -23,8 +27,42 @@ public sealed partial class Scenario5_Show : Page public Scenario5_Show() { this.InitializeComponent(); + this.DataContext = this; } + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + var ignore = AppointmentGet(); + } + + private async Task AppointmentGet() + { + var dateToShow = DateTime.Now.AddDays(1); + var duration = TimeSpan.FromHours(24); + + AppointmentStore calendar = await AppointmentManager.RequestStoreAsync(AppointmentStoreAccessType.AllCalendarsReadOnly); + + // Specify which values to retrieve + FindAppointmentsOptions options = new FindAppointmentsOptions(); + options.FetchProperties.Add(AppointmentProperties.Subject); + options.FetchProperties.Add(AppointmentProperties.StartTime); + options.FetchProperties.Add(AppointmentProperties.Duration); + options.FetchProperties.Add(AppointmentProperties.AllDay); + options.FetchProperties.Add(AppointmentProperties.Details); + options.FetchProperties.Add(AppointmentProperties.DetailsKind); + + var iteratingAppointments = await calendar.FindAppointmentsAsync(dateToShow, duration, options); + var items = from a in iteratingAppointments select a; + + await rootPage.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, + () => { items.ToList().ForEach(a => this.appointments.Add(a)); } + ); + } + + private ObservableCollection appointments = new ObservableCollection(); + public ObservableCollection Appointments => appointments; + /// /// Show the default appointment provider at a point in time 24 hours from now. /// @@ -33,7 +71,8 @@ public Scenario5_Show() private async void Show_Click(object sender, RoutedEventArgs e) { var dateToShow = DateTime.Now.AddDays(1); - var duration = TimeSpan.FromHours(1); + var duration = TimeSpan.FromHours(24); + await Windows.ApplicationModel.Appointments.AppointmentManager.ShowTimeFrameAsync(dateToShow, duration); rootPage.NotifyUser("The default appointments provider should have appeared on screen.", NotifyType.StatusMessage); } diff --git a/Samples/Appointments/shared/Scenario5_Show.xaml b/Samples/Appointments/shared/Scenario5_Show.xaml index 4524869005..6e2d8217a6 100644 --- a/Samples/Appointments/shared/Scenario5_Show.xaml +++ b/Samples/Appointments/shared/Scenario5_Show.xaml @@ -25,7 +25,50 @@ Shows the default appointments provider app at a particular time and date. -