Since this is Xamarin Forms, I'm assuming you're using Allan Ritchie's Acr.XamForms.SignaturePad
classes.
The SignaturePadView
class exposes a method: LoadDrawPoints
, that allows you to load the signature data into the view. Since this is a method, you can't really databind to it, but you can add code to the hosting view to load the signature:
// NOTE: The below assumes that
// A) You're using MVVM (as you should :) )
// B) The ViewModel class name is MyViewModelClassName (change appropriately)
// C) The property on the VM that exposes the signature points is named SignaturePoints (change appropriately)
protected override OnAppearing() {
LoadSignature();
}
protected override OnBindingContextChanged() {
LoadSignature();
}
private void LoadSignature() {
var vm = this.BindingContext as MyViewModelClassName;
if (vm != null && vm.SignaturePoints != null) {
this.signaturePadView.LoadDrawPoints(vm.SignaturePoints);
}
}
Lastly, you mention that you're saving the signature as a byte array; the above code assumes that it's an array of DrawPoint
, which is a pair of floats, so you'd need to reverse whatever conversion you're currently doing.