简体   繁体   中英

Open the windows phone 8 windows calender through c# code

I would like to open the windows 8 calender through c# code once a button is pressed by the user. Is it possible to open the calender? and if so how can this be achieved?

Thank you in advance :)

If you have a Windows Phone application that has a page with a button named ButtonAppointments.

 private void ButtonAppointments_Click(object sender, RoutedEventArgs e)
    {
        Appointments appts = new Appointments();

        //Identify the method that runs after the asynchronous search completes.
        appts.SearchCompleted += new EventHandler<AppointmentsSearchEventArgs>(Appointments_SearchCompleted);

        DateTime start = DateTime.Now;
        DateTime end = start.AddDays(7);
        int max = 20;

        //Start the asynchronous search.
        appts.SearchAsync(start, end, max, "Appointments Test #1");
    }

    void Appointments_SearchCompleted(object sender, AppointmentsSearchEventArgs e)
    {
        //Do something with the results.
        MessageBox.Show(e.Results.Count().ToString());
    }

Refered from : How to access calendar data for Windows Phone 8

Try this

private void ButtonAppointments_Click(object sender, RoutedEventArgs e)
    {
        Appointments appts = new Appointments();

        appts.SearchCompleted += new EventHandler<AppointmentsSearchEventArgs>(Appointments_SearchCompleted);

        DateTime start = DateTime.Now;
        DateTime end = start.AddDays(7);
        int max = 10;

        //Start the asynchronous search.
        appts.SearchAsync(start, end, max, "Appointment");
    }

还要添加它以显示结果

MessageBox.Show(e.Results.Count().ToString());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM