Aditya Patil
Aditya Patil

Reputation: 146

Reminder alert box click open page with details: Windows Phone app

I am writing code for Windows Phone application, in this I am showing the Reminder Alert Box when time will come, I want when I will tap on that reminder alert box, it will navigate to one page with those Reminders details. So How I can do.

_Content = TextField.Text;
_Date = dpkDate.Value.Value;
_Time = tpkDate.Value.Value.TimeOfDay;
_Date = _Date.Date + _Time;

Uri navigationUri = new Uri("/MainPage.xaml", UriKind.Relative); //Here I want to send parameter cause to show all details about reminder on MainPage.xaml

    var newReminder = new Reminder(_Date.ToString())
    {
        Content = _Content,    
        BeginTime = _Date,    
        RecurrenceType = RecurrenceInterval.None,    
        NavigationUri = navigationUri,    
        // sound= new Uri("music1.wav",UriKind.Relative)
    };

    ScheduledActionService.Add(newReminder);

So Can I do this? & if yes, How?

Note: Sorry for indentation, I can't indent on this page so if possible someone edit the post with proper indentation.

Upvotes: 0

Views: 148

Answers (1)

James
James

Reputation: 802

Two ways you can do this:

1) You can pass parameters as you would in a query string in a normal URL. Eg:

Uri navigationUri = new Uri("/MainPage.xaml?date=" + _Date.ToString(), UriKind.Relative);

On the page you navigate to you can get the values like so:

string strDate = "";
NavigationContext.QueryString.TryGetValue("date", out strDate);
DateTime dtmDate = DateTime.Parse(strDate);

2) You can store your values in IsolatedStorage before navigating and retrieve them on the navigated to page. Eg:

starting page:

IsolatedStorageSettings.ApplicationSettings["date"] = _date;

target page

if (IsolatedStorageSettings.ApplicationSettings.Contains("date"))
{
DateTime dtmDate = (DateTime)IsolatedStorageSettings.ApplicationSettings["date"];
}

So, you could store your variables in an object and pass that via IsolatedStorage:

public class Reminder
{
    public string _Content { get; set; }
    public DateTime _Date { get; set; }
    public DateTime _Time { get; set; }
    public DateTime _DateTime { get; set; }
}

Reminder objReminder = new Reminder();
objReminder._Content = TextField.Text;
objReminder._Date = dpkDate.Value.Value;
objReminder._Time = tpkDate.Value.Value.TimeOfDay;
objReminder._DateTime = _Date.Date + _Time;

IsolatedStorageSettings.ApplicationSettings["objReminder"] = objReminder;

Then on your target page retrieve your object:

if (IsolatedStorageSettings.ApplicationSettings.Contains("objReminder"))
{
    Reminder objReminder = (Reminder)IsolatedStorageSettings.ApplicationSettings["objReminder"];
    //Get your values and do what you want
}

Hope this helps.

Upvotes: 1

Related Questions