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

Xamarin.Forms - CommandParameter is always null

$
0
0

When a button is clicked I'd like to pass a control's property to the view model using a Command / CommandParameter.

However, when I debug the Command method - Agree() - the CommandParameter I receive is always null. Do I have to set some sort of additional context in the button that calls the Command?

Xaml from view:

<controls:SignaturePad 
            x:Name="signaturePad"/>

<Button
            x:Name="agreeButton"
            Text="I AGREE"
            Command="{Binding AgreeCommand}"
            CommandParameter="{Binding Source={x:Reference signaturePad}, Path=Bytes}"/>

Command definition in ViewModel:

private readonly ReactiveCommand<byte[], Unit> agreeCommand;

public MyViewModel()
{
    this.agreeCommand = ReactiveCommand.CreateFromObservable<byte[], Unit>(
        this.Agree,
        canAgree,
        scheduler);
}

public ReactiveCommand<byte[], Unit> AgreeCommand => this.agreeCommand;

private IObservable<Unit> Agree(byte[] signature)
{
    this.signature = signature;  // Only ever see null here

    // Other system.reactive code...
}

Viewing all articles
Browse latest Browse all 89864

Trending Articles



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