C# 如何将事件提醒添加到我的windows phone 7应用程序
我正在windows phone 7中构建一个应用程序,需要在其中添加事件提醒。单击按钮时,应设置提醒。我的cs文件是:C# 如何将事件提醒添加到我的windows phone 7应用程序,c#,windows-phone-7,C#,Windows Phone 7,我正在windows phone 7中构建一个应用程序,需要在其中添加事件提醒。单击按钮时,应设置提醒。我的cs文件是: namespace KejriwalPhoneApp { public partial class EventDetails : PhoneApplicationPage { public EventDetails() { InitializeComponent(); ApplicationBar = new Applica
namespace KejriwalPhoneApp
{
public partial class EventDetails : PhoneApplicationPage
{
public EventDetails()
{
InitializeComponent();
ApplicationBar = new ApplicationBar();
ApplicationBar.Mode = ApplicationBarMode.Default;
ApplicationBar.Opacity = 1.0;
ApplicationBar.IsVisible = true;
ApplicationBarIconButton home = new ApplicationBarIconButton();
home.IconUri = new Uri("/Image/icon_home_deselect.png", UriKind.Relative);
home.Text = "Home";
ApplicationBar.Buttons.Add(home);
home.Click += new EventHandler(home_Click);
ApplicationBarIconButton share = new ApplicationBarIconButton();
share.IconUri = new Uri("/Image/icon_share_deselect.png", UriKind.Relative);
share.Text = "Share";
ApplicationBar.Buttons.Add(share);
share.Click += new EventHandler(share_Click);
ApplicationBarIconButton news = new ApplicationBarIconButton();
news.IconUri = new Uri("Image/icon_news_deselect.png", UriKind.Relative);
news.Text = "News";
ApplicationBar.Buttons.Add(news);
news.Click += new EventHandler(news_Click);
ApplicationBarIconButton events = new ApplicationBarIconButton();
events.IconUri = new Uri("/Image/icon_event_deselect.png", UriKind.Relative);
events.Text = "Video";
ApplicationBar.Buttons.Add(events);
events.Click += new EventHandler(events_Click);
}
void events_Click(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/Events.xaml", UriKind.Relative));
}
void news_Click(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/News.xaml", UriKind.Relative));
}
void share_Click(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/share.xaml", UriKind.Relative));
}
void home_Click(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
}
private void Image_Back(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Events.xaml", UriKind.Relative));
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var imagePath = "";
var eventdate = "";
var location = "";
var utimee = "";
var tzone = "";
var ename = "";
var desc = "";
//check if particular parameter available in uri string
if (this.NavigationContext.QueryString.ContainsKey("image_path"))
{
//if it is available, get parameter value
imagePath = NavigationContext.QueryString["image_path"];
eventimage.Source = new BitmapImage(new Uri(@"http://political-leader.vzons.com/ArvindKejriwal/images/uploaded/" + imagePath, UriKind.Absolute));
}
if (this.NavigationContext.QueryString.ContainsKey("Time_Zone"))
{
tzone = NavigationContext.QueryString["Time_Zone"];
timezone.Text = tzone;
}
if (this.NavigationContext.QueryString.ContainsKey("uTime"))
{
utimee = NavigationContext.QueryString["uTime"];
utime.Text = utimee;
}
if (this.NavigationContext.QueryString.ContainsKey("Event_Date"))
{
//if it is available, get parameter value
eventdate = NavigationContext.QueryString["Event_Date"];
evntdate.Text = eventdate;
}
if (this.NavigationContext.QueryString.ContainsKey("Location"))
{
//if it is available, get parameter value
location = NavigationContext.QueryString["Location"];
loc.Text = location;
}
if (this.NavigationContext.QueryString.ContainsKey("Event_Name"))
{
//if it is available, get parameter value
ename = NavigationContext.QueryString["Event_Name"];
enamee.Text = ename;
}
if (this.NavigationContext.QueryString.ContainsKey("Event_Description"))
{
//if it is available, get parameter value
desc = NavigationContext.QueryString["Event_Description"];
edescription.Text = desc;
}
}
}现在,当点击提醒按钮时,我希望设置utimee、tzone字段,并弹出消息“事件提醒添加成功”
我不知道如何做您可以执行以下步骤: 1.从webservice获取作为全局变量的值: 事件日期、位置、utimee、tzone、ename、描述 2.点击提醒按钮,执行点击方式
private void BtnReminderClick(object sender, EventArgs e)
{
RegisterReminder();
}
3.做提醒登记
private void RegisterReminder()
{
var reminder = ScheduledActionService.Find(ename) as Reminder ?? new Reminder(ename);
reminder.Title = ename;
reminder.Content = desc;
// parse eventDate,utimee to beginDateTime
reminder.BeginTime = DateTime.Parse(eventDate).Date + DateTime.Parse(utimee).TimeOfDay;
reminder.ExpirationTime = reminder.BeginTime.AddDays(1);
reminder.RecurrenceType = RecurrenceInterval.None;
if (ScheduledActionService.Find(ename) == null)
ScheduledActionService.Add(reminder);
else
ScheduledActionService.Replace(reminder);
MessageBox.Show("reminder set succeed!");
}
你试过什么了吗?你说的“我想设置utimee、tzone字段,然后我会弹出一个窗口”是什么意思?@ChrisShao点击提醒按钮时,会看到我从web服务获得的数据,即日期、时区和utime,这些数据应该在我的设备中设置,我应该会收到一条弹出消息,提示已设置。我能把事情说清楚吗?是的,你应该根据你的数据在提醒中设置标题、内容、开始时间、过期时间和重复发生类型,之后,你可以弹出一条消息。嗨,@user3156298,请阅读我的代码。我收到一些错误:ename、desc、begindatetime在当前上下文中不存在。我知道,你可以设置aname、desc eventDate,utimee作为全局变量。beginDateTime是一个DateTime类型的变量,可以从eventDate和utimee解析。我已经设置了这些全局变量,即ename、desc、eventDate和utimee。你能在你的代码中解析beginDateTime吗?它工作得很好。谢谢你能告诉我一件事吗。。。是否有办法在中央显示消息框?默认消息框位于屏幕顶部。这是wp的默认syle。
private void RegisterReminder()
{
var reminder = ScheduledActionService.Find(ename) as Reminder ?? new Reminder(ename);
reminder.Title = ename;
reminder.Content = desc;
// parse eventDate,utimee to beginDateTime
reminder.BeginTime = DateTime.Parse(eventDate).Date + DateTime.Parse(utimee).TimeOfDay;
reminder.ExpirationTime = reminder.BeginTime.AddDays(1);
reminder.RecurrenceType = RecurrenceInterval.None;
if (ScheduledActionService.Find(ename) == null)
ScheduledActionService.Add(reminder);
else
ScheduledActionService.Replace(reminder);
MessageBox.Show("reminder set succeed!");
}