Hi!
If the pain comes on bending the knee, then it could be due to Patellofemoral syndrome. This happens due to malialignment of the knee cap on bending the knee (and hence any imaging study has to be taken with the knee bent), injury to the knee (you may have sustained it in past), flat feet, over tight or over lax muscles around the knee joint. All these aspects will have to be investigated by your doctor. Other possibilities are bursitis (inflammation of fluid filled sac over joints), tendonitis (inflammation of cords joining muscles to bones) or due to weakness of patellar bone. Please discuss all these possibilities with your treating doctor. Take care!
The medical advice given should not be considered a substitute for medical care provided by a doctor who can examine you. The advice may not be completely correct for you as the doctor cannot examine you and does not know your complete medical history. Hence this reply to your post should only be considered as a guiding line and you must consult your doctor at the earliest for your medical problem.