Adding a Pushpin on MapControl Tap event

I'm trying to add a Pushpin to my MapControl on Tap. The problem I am facing is, the GestureEventArgs passes a Map relative co-ordinate for eg:

X = 216
Y = 197

Due to this I am not able to assign the Co-ods on a Pushpin to Add into the map. Here's exactly what I am doing.

private void MainMap_Tap(object sender, GestureEventArgs e)
        Point p = e.GetPosition(this.MainMap);
        GeoCoordinate g = new GeoCoordinate();
        g = MainMap.ViewportPointToLocation(p);

        MyPin.Location = g;

My code breaks due to a Null Reference Error at MyPin.Location = g. In g I get values like

g = {-0.00446319579627641, 0.00369071960449219}


Probably because your MyPin is not initialized.

You cannot set the Location of a Pushpin if it's null.

Need Your Help

ASP.NET MVC 2 Problem with custom ModelValidator

c# .net

I am trying to validate that either of 2 textbox fields in my view have a value supplied. I made this Model Validator: