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

4

1 回答 1

0

您需要创建 BadgeElement 的自定义版本,并且基本上为图像引发一个事件,该事件与为文本引发事件是分开的。

幸运的是,整个源代码都可用,因此您只需复制/粘贴 BadgeElement、重命名、创建新的唯一键并对其进行修改。

于 2013-03-31T01:56:33.860 回答