1
Answer

OnNavigatedto method problem

Aditya Patil

Aditya Patil

10y
1k
1
HOW I CAN DECIDE THAT CONTROL CAME FROM lISTBOX ITEM SELECTED ITEM AND CONTROL CAME FROM REMINDER ALERT BOX TAP? PLEASE TELL ME.
FOR REFERENCE CODE, I TRIED FLAGS BUT ITS NOT WORKING.

basically, I am already written few lines of code when I select item from ListBox in onnavigated method
But again I want to write code for Reminder Alert Box tap method and pass parameter, so collision happens between that, either reminder tap works or either listbox item selection worked
Not getting.

I written below code
protected override void OnNavigatedTo(NavigationEventArgs e)
  {
  dbConn = new SQLiteConnection(DB_PATH);
  // Create the table Task, if it doesn't exist.
  dbConn.CreateTable<Task>();
  // Retrieve the task list from the database.

  try
  {
  if(flagr==false)
  {
 
  String note1 = NavigationContext.QueryString["param1"].ToString();
  String date1 = NavigationContext.QueryString["param2"].ToString();
  String time1 = NavigationContext.QueryString["param3"].ToString();
  String prio = NavigationContext.QueryString["param4"].ToString();

  TextField.Text = note1;
  dpkDate.Value = DateTime.Parse(date1);
  tpkDate.Value = DateTime.Parse(time1);
  if (prio == "High")
  priority.SelectedIndex = 0;
  else if (prio == "Medium")
  priority.SelectedIndex = 1;
  else
  priority.SelectedIndex = 2;
  flagr = true;

  }

  if (flag == false)
  {
 
  id = NavigationContext.QueryString["selectedItem"].ToString();
  tempid = id;
  selectionflag = true; //if came from listboxitem
  //MessageBox.Show(id); //this retrive the index of selected item and display in message
  flag1 = true;
  var note = dbConn.Query<Task>("select * from task where Id='" + id + "'").FirstOrDefault();
  if (note == null)
  {
  MessageBox.Show("Note Not Present in DataBase");
  }
  else
  {
  dpkDate.Value = DateTime.Parse(note.Date);
  tpkDate.Value = DateTime.Parse(note.Time);
  TextField.Text = note.Text;
  if (note.Priority == "High")
  priority.SelectedIndex = 0;
  else if (note.Priority == "Medium")
  priority.SelectedIndex = 1;
  else
  priority.SelectedIndex = 2;
  flag = true;
  _Date = dpkDate.Value.Value;
  _Time = tpkDate.Value.Value.TimeOfDay;
  _Date = _Date.Date + _Time;
  ScheduledActionService.Remove(_Date.ToString()); //Delete Reminder
  //MessageBox.Show("Reminder Deleted");
 
  }
  }
  else
  {
  id = null;
  var note = dbConn.Query<Task>("select * from task where Id='" + id + "'").FirstOrDefault();
  }
  }
  catch { }
  // Create the database connection.

  }
Answers (1)