I have created a renderer for the SignaturePad (I called it SignaturePanel to avoid confusing myself with namespaces) to use it in my Xamarin.Forms project. It seems to be working, except that when it is added in a StackLayout it takes all the remaining space on the screen.
See the code below - the SignaturePanel shows from the top of the screen to the bottom edge, and the button is not squeezed in at the bottom as I expect. If I move the button above the SignaturePanel it shows the button at the top then the SignaturePanel as I expect.
MyPage.cs (in Xamarin Forms project):
namespace XamarinFormsPoc
{
public class MyPage : ContentPage
{
public MyPage ()
{
var signaturePanel = new XamarinFormsPoc.SignaturePanel ();
Button button = new Button
{
Text = "Continue"
};
Content = new StackLayout {
Children = {
signaturePanel,
button
}
};
}
}
}
SignaturePanel.cs (in Xamarin Forms project):
namespace XamarinFormsPoc
{
public class SignaturePanel : View
{
public SignaturePanel ()
{
}
}
}
SignaturePanelRenderer.cs (in Xamarin Android project):
[assembly: ExportRenderer (typeof(XamarinFormsPoc.SignaturePanel), typeof(XamarinFormsPoc.Android.SignaturePanelRenderer))]
namespace XamarinFormsPoc.Android
{
public class SignaturePanelRenderer : NativeRenderer
{
private SignaturePadView _pad;
protected override void OnModelChanged (VisualElement oldModel, VisualElement newModel)
{
base.OnModelChanged (oldModel, newModel);
if (this._pad == null) {
this._pad = new SignaturePadView (base.Context);
this._pad.Touch += SignaturePadTouch;
base.SetNativeControl (this._pad);
}
}
protected void SignaturePadTouch (object sender, TouchEventArgs args)
{
// ... snip ...
}
}
}
Any ideas why this is? How do I get the SignaturePad/SignaturePanel to respect the StackLayout and leave space for the button?
Since I'm new to this if you see anything else wrong or I could improve in the above, feel free to suggest!
Thanks.