A couple of the posts in this thread seem a tad confused
. Just for the record, "Patella" isn't a condition. Patella is the correct name for your kneecap. The stifle joint is analogous to our knee. Horses' stifles are designed so that they can "lock," allowing a horse to sleep while standing up. There is a place where the patella sits to do this. This is a normal part of the way the leg functions. Unfortunately, in some horses, the patella will slip into place when it isn't meant to, or won't come out when it's supposed to. That's a locking stifle.
When we talk about straight stifles, we don't mean straight like a ruler, just not as much of an angle as we would prefer to see. As Leia said, it seems to have to do with the lengths of the bones and their relationships to each other. Muscle development plays a role, too. As does activity - I knew a QH mare that would lock up if she was stalled for more than a few hours (like overnight.) As long as she was able to move around, she was fine. As to whether it is hereditary - well, the condition itself isn't, but the conformation that can make it likely to occur certainly can be. A lot of young horses go through a stage where they do this, and outgrow it as they mature. It can appear in an otherwise sound horse as a result from an injury in the stifle area.
There are a couple of different surgeries that are done to try to correct this problem, and they meet with varied success. The more radical surgery actually severs the ligament that allows the patella to get into its notch. This is what was finally done to Leia's Kody. Kody's legs no longer lock, at any time. Kody is now apparently pain-free (Hooray!!), but the trade-off is, he can no longer sleep standing up. (Sorry, Leia, I don't mean to steal your thunder. I know of several horses that have had this surgery, but Kody's the only one whose name I know!)