在签名板 Xamarin Forms 上绑定签名字节数组的方法如下:
private byte[] signatureData;
public byte[] SignatureData
{
get { return signatureData; }
set { SetProperty(ref signatureData, value); }
}
<local:SignatureView SignatureData="{Binding SignatureData}" />
public class SignatureView : ContentView
{
private SignaturePadView signaturePad;
public SignatureView()
{
signaturePad = new SignaturePadView();
signaturePad.StrokeCompleted += OnStrokeCompleted;
Content = signaturePad;
}
private void OnStrokeCompleted(object sender, EventArgs e)
{
var image = signaturePad.GetImage();
SignatureData = ConvertImageToByteArray(image);
}
private byte[] ConvertImageToByteArray(SKImage image)
{
using (var data = image.Encode())
{
return data.ToArray();
}
}
public static readonly BindableProperty SignatureDataProperty =
BindableProperty.Create(nameof(SignatureData), typeof(byte[]), typeof(SignatureView), null);
public byte[] SignatureData
{
get { return (byte[])GetValue(SignatureDataProperty); }
set { SetValue(SignatureDataProperty, value); }
}
}
对于腾讯云相关产品和产品介绍链接地址,由于要求不能提及具体的云计算品牌商,建议你在腾讯云官方网站上查找相关产品和文档,以获取更详细的信息和链接地址。
领取专属 10元无门槛券
手把手带您无忧上云