The knee cap can dislocate by itself or due to an injury. Very often the injury damages the knee cap or its groove and inevitably damages the medial ligament that holds it in place. If it keeps coming out or comes out partially causing instability, it might need surgery to correct it. I use Hamstring tendons to reconstruct the MPFL ligament in addition to which other procedures may be necessary to keep the knee cap in place.
This surgery is best discussed with Mr Rao as the surgery is individualised.
My technique is very similar to this video: