Draw square throwing exception at method MapRectangle.SetShapeParameters

2 posts, 0 answers
  1. DMC Helpdesk
    DMC Helpdesk avatar
    52 posts
    Member since:
    Nov 2007

    Posted 22 Dec 2011 Link to this post


    I am trying to draw a sequare using the MapRectangle control.The sample I found at this post (http://www.telerik.com/community/forums/wpf/map/draw-square.aspx) is throwing exception at the highlighted line:

    private void SetShapeParameters()
                if (this.MapControl != null)
                    Rectangle rect = this.Shape as Rectangle;
                    Size size = this.MapCanvas.GetPixelSize(this.Location, this.RadiusX, this.RadiusY);
                    if (!double.IsNaN(size.Width) && !double.IsInfinity(size.Width))
                        rect.RadiusX = size.Width;
                    if (!double.IsNaN(size.Height) && !double.IsInfinity(size.Height))
                        rect.RadiusY = size.Height;

    The exception is "Object reference not set to an instance of an object" and it is because this.MapCanvas is null.

    Any help will be highly appreciated.

  2. Andrey
    Andrey avatar
    1681 posts

    Posted 23 Dec 2011 Link to this post


    We are aware of this problem in older versions of RadControls (2011 Q1 or Q2) and it has already been fixed.

    In addition, the sample you use was created for older than 2011 Q1 version of map control and it contains unnecessary functionality. I have attached a modified solution which does not contain it. Also it implements a correct order for drawing rectangle and it does not cause the exception.

    All the best,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
Back to Top