Is gaining weight related to pattelar pain?

It can. More important is perhaps the imbalance between your quadriceps and hamstring muscles. Also consider orthotics which may help with your biomechanics of walking which may be affecting the torque around your patella.