Bicycles stay upright because the rider can steer while in motion.
A normal trackstand by a normal person is actually a bit of forward and backward movement, as noted in above posts. The key is moving backward - once you accomplish that you can do a "trackstand" for a while.
A second rule comes into play here, one of physics (equal and opposite motion). If you move your bike (let's call it 17 lbs) forward 10 inches, your body (let's call it 170 lbs) moves backward 1 inch. This means you can effectively move your bike backward even on a downhill.
I have terrible balance, I'm pretty uncoordinated, but I can do a trackstand (or "road stand") at a light, on upward or downward sloping roads.
http://sprinterdellacasa.blogspot.co...ackstands.html
A helmet cam view of some trackstands I did on a variety of gentle road slopes: