Button Command binding issue

THenny12THenny12 Member ✭✭

in my xaml I have a listview with buttons in each view cell.
<ListView ItemsSource="{Binding FoodList}"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> <StackLayout Orientation="Horizontal" HorizontalOptions="Fill"> <Label Text="{Binding Name}" FontSize="24"/> <Button x:Name="btn_minus" Text="-" Command="{Binding BtnMinusCommand}" CommandParameter="{Binding Source={x:Reference btn_minus}, Path=BindingContext}" /> <Label Text="{Binding Quantity, Mode=TwoWay}" FontSize="24" /> <Button x:Name="btn_plus" Text="+" FontSize="24" Command="{Binding BtnPlusCommand}" CommandParameter="{Binding Source={x:Reference btn_plus}, Path=BindingContext}" /> </StackLayout> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>
The buttons are bound to commands in my viewmodel to increment/decrement the objects in the list
public TakeOrderViewModel() { FoodList = menuService.getMenu(); BtnMinusCommand = new Command<IFoodItems>(DecreaseQuantity); BtnPlusCommand = new Command<IFoodItems>(IncreaseQuantity); } void DecreaseQuantity(IFoodItems food) { food.DecreaseQuantity(); } void IncreaseQuantity(IFoodItems food) { food.IncreaseQuantity(); }
When i run my application pressing the buttons does nothing. How can i check if the bindings are correct?


Sign In or Register to comment.