Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

NControl / NGraphics - Draw method not firing.

$
0
0

I've recently discovered the NGraphics & NControl libraries available to use along side Xamarin.Forms, and it seems great so far.

The problem I'm having is that the draw method never gets called, and I'm not too sure where I'm going wrong. My code is below (I've stripped out all the unnecessary bits), any help is greatly appreciated!

public class CustomGrid : NControlView
    {
        public CustomGrid ()
        {
            base.Invalidate (); //Invalidating the control doesn't redraw the control
            Content = new Label {BackgroundColor = Xamarin.Forms.Color.Transparent};
            BackgroundColor = Xamarin.Forms.Color.Blue;
        }


        public override void Draw (NGraphics.ICanvas canvas, NGraphics.Rect rect)
        {
            base.Draw(canvas, rect);
            //foreach column draw the grid line on the right
            foreach (CustomColumn c in ColumnCollection) 
            {
                canvas.DrawLine (c.CoOrds.startX,c.CoOrds.startY, c.CoOrds.EndX, c.CoOrds.EndY,Colors.White);
            }

            //for each row draw the bottom grid line
            foreach (CustomRow r in RowCollection) 
            {
                canvas.DrawLine (r.CoOrds.startX,r.CoOrds.startY, r.CoOrds.EndX, r.CoOrds.EndY,Colors.White);
            }
        }

        public List<CustomColumn> ColumnCollection { get; set; }
        public List<CustomRow> RowCollection { get; set; }


    }

Just to ensure I wasn't going crazy, I copied and pasted the example found on the NControl GitHub Repo and that doesn't seem to work either: link here.

Thank You in advance!


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>