Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

[Xamarin.Forms] Setting 'Points' requires the view be visible #93

Open
GenPike opened this issue Aug 31, 2017 · 8 comments
Open

[Xamarin.Forms] Setting 'Points' requires the view be visible #93

GenPike opened this issue Aug 31, 2017 · 8 comments
Labels

Comments

@GenPike
Copy link

GenPike commented Aug 31, 2017

Method "LoadPoints()" only available for platform specific implementation, but you can't use it in PCL. Is it in the roadmap/ it is not planned?
Also tried to use "Points" property, but it's setter is dependent from event, which is private. Maybe it is another easier way to load points?

@mattleibow
Copy link
Contributor

The Points property is the correct way to assign the points.

It should accept any collection of Xamarin.Forms Point. In what way can't you use this?

@GenPike
Copy link
Author

GenPike commented Sep 1, 2017

The problem is that we are trying to load points to Empty SignaturePad.

From source code we can see implementation of Points property (https://github.com/xamarin/SignaturePad/blob/master/src/SignaturePad.Forms.Shared/SignaturePadCanvasView.cs):

public IEnumerable<Point> Points
{
	get { return GetSignaturePoints (); }
	set { SetSignaturePoints (value); }
}

If we will look into SetSignaturePoints() method:

private void SetSignaturePoints (IEnumerable<Point> points)
{
	PointsSpecified?.Invoke (this, new PointsEventArgs { Points = points });
}

As a result, it is possible to load points to Pad in case you have anything on it (handwritten by user before). But if it's empty (so page just opened), you can't...
Am I right?

Attaching file with sample points array variable. Try to add SignaturePad control on Page.xaml, then in Page.xaml.cs set the Points property, before any actions will be done from UI. For me Points property just not change.
Points.txt

@mattleibow
Copy link
Contributor

Thanks for pointing this out. I did some investigation, and I now know where the issue lies, but I am not sure on what the best way to fix it.

It is not exactly an issue (but still is), since this is how Xamarin.Forms works. As the Points property requires the native view to have been instantiated, we have to wait. Unfortunately, I think the native view is only instantiated later on, about the time the page is made VISIBLE on the screen (eg: after navigation / in OnAppearing)

We could find some way to temporarily store the points until the view is made visible, but I am waiting on the Forms team for confirmation and suggestions.

In the meantime, I would suggest setting the points in the OnAppearing method or in the Appearing event on the page.

@mattleibow mattleibow added the bug label Sep 1, 2017
@mattleibow
Copy link
Contributor

Just for reference, I have uploaded a test project that demonstrates the issue:

LifecycleTest.zip

@GenPike
Copy link
Author

GenPike commented Sep 5, 2017

@mattleibow, thank you for advice with setting points in the OnAppearing, works nicely! After debug I understood that tried to initilaize Points before OnAppearing occur, so agree it is not real issue.

But small suggestion - it will be good to extend examples documentation. In GitHub docs LoadPoints() method is mentioned (not available in SignaturePad.Forms) and no example with setting Points property, so it was a bit not clear how to load points with Xamarin.Forms approach.
All in all - wonderful package!

@staunchman
Copy link

In my case, I tried to save the signature.Points. After that I recall it again to load into the pad but it's empty nothing appearing just the pad. I've worked in Xamarin Forms.

@mattleibow
Copy link
Contributor

@staunchman Due to the way Xamarin.Forms works, you will have to load the points in the OnAppearing event: #93 (comment)

@mattleibow mattleibow reopened this Nov 9, 2017
@mattleibow mattleibow changed the title When LoadPoints() will be available in SignaturePad.Forms package? [Xamarin.Forms] Setting 'Points' requires the view be visible May 18, 2018
@nativenolde
Copy link

hey @mattleibow, thank you for the Workaround.
what about the efforts to make the signature pad mvvm capable? Are there any news on that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants