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...
}