How to pass parameter to method inside a Command object in Xamarin.forms ?

AliRaza.5445AliRaza.5445 PKMember ✭✭✭

` public class ProductDetailsPageViewModel
{

    public ICommand AddToCartCommand { get; private set; }

public ProductDetailsPageViewModel(Product selectedProduct)

    {
        AddToCartCommand=new Command<Product>(AddToCartMethod(selectedProduct))
    }

private void AddToCartMethod(Product p)
{
//cartList.Add();
}`

Hi , I want to pass parameter to Command object but I am unable to achieve this thing. Can you help me why I am doing it wrong. In view, I have binded Button Click to AddToCartCommand. Please review the code above and help me how to achieve this ?
Thanks

Sign In or Register to comment.