0

I have amended the TODO list app to use a badge element instead of the boolean element as follows:

    protected void PopulateTable()
    {
        tasks = TaskManager.GetTasks().ToList ();
        UIImage ticked = new UIImage("checkbox_checked.png");
        UIImage unticked = UIImage.FromFile("checkbox_unchecked.png");

        Root = new RootElement("Tasky") {
            new Section() {
                from t in tasks
                select (Element) new BadgeElement(t.Completed ? ticked : unticked, (t.Name==""?"<new task>":t.Name), delegate {
                        Console.WriteLine("???");

                    })
            }
        }; 
    }

Is it possible to check to see if the user has clicked an icon rather than the text, and change the behaviour? Essentially I want to do this...

        var task = tasks[indexPath.Row];

        if(clickedIcon) {
            currentTask = task;
            task.Completed = !task.Completed;
            TaskManager.SaveTask(currentTask);
        } else {
            ShowTaskDetails(task);
        }

But I don't see any parameters inside IndexPath that allow me to access the column or the tapped element.

Any ideas

digiguru
  • 12,724
  • 20
  • 61
  • 87

1 Answers1

0

You need to create a custom version of the BadgeElement, and basically raise an event for the image that is separate from raising an event for the text.

Luckily for you, the whole source code is available, so you can just copy/paste BadgeElement, rename it, create a new unique key and modify it.

digiguru
  • 12,724
  • 20
  • 61
  • 87
miguel.de.icaza
  • 32,654
  • 6
  • 58
  • 76