Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Binding to call a method of the binding class from a button.

$
0
0

Hey,

So i have a View that i have bound to a List of Timer objects called Timers (custom class i have made), and in the view i have added a start and remove button. when a user clicks start i want them to be able to call the relevant timer object associated with the button underlying method startTimer(). How can i do this?

View code:

<ListView.ItemTemplate>




Timer Class:
public class Timer
{
public int _startTime { get; set;}
public bool _hasStarted{ get; set; }
public string _name { get; set; }

    public Timer (string name, int startTime, bool hasStarted = false)
    {
        _name = name; 
        _startTime = startTime; 
        _hasStarted = hasStarted; 
    }

    public void startTimer(){
        //do something here
    }
}

Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>