How to redraw on canvas based on a value from code.

Hi, I'm creating a pin login screen in a Xamarin Forms app. I've successfully created the small rectangles/squares to show the user the empty pin fields on load based on the PaintSurface call.

There are 4 seperate canvases for each pin integer

On the page i also have a hidden entry that triggers a TextChanged method when a number is pressed on the key pad thus counting the length of the entry field.

If the entry field length is 1 then add an additional drawRect in the first canvas
If the entry field length is 2 then add an additional drawRect in the second canvas and so on and so on.

eg

How do i access the first canvas from the TextChanged to update the first canvas when the entry length is 1?

I've tried placing the canvas objects as class variables and tried to access them on a keypad press but the app seems to crash.

It seems that the canvas can only be manipulated one on the pageload or I'm missing something, I've looked around but can't seem to find out how to access a particualr canvas after PaintSurface has triggered on load.

Thanks

Answers

  • CostasAletrariCostasAletrari USMember ✭✭

    I managed to get it working by also drawing the filled in DrawRect and hiding them on page load. I then set canvas.Isvisable to true based on the length of the entry field.

Sign In or Register to comment.