I have a listview of objects each with two buttons that i want to increment/decrement a variable on a object
<ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout Orientation="Horizontal" HorizontalOptions="Fill"> <Label Text="{Binding Name}" FontSize="24"/> <Button x:Name="btn_minus" Text="-"Clicked="btn_minus_Clicked"/> <Label Text="{Binding Quantity, Mode=TwoWay}" FontSize="24" /> <Button x:Name="btn_plus"Text="+"FontSize="24"Clicked="btn_plus_Clicked"/> </StackLayout> </ViewCell>
Each object has a quantity and two functions to increment/decrement
public class GatorStick { public int Quantity { get; set; } public GatorStick() { Quantity = 0; } public void IncreaseQuantity() { ++Quantity; } public void DecreaseQuantity() { if (Quantity == 0) { } else --Quantity; } }
How can i get those buttons to call the increase/decrease methods for each object in the list independent of each other?
Sorry for the bad formatting i tried everything to get it correct.