My foal tried the whole 'walking away' thing when I was teaching him to pick up his feet as well. Then he started to stretch out and bow, almost as if he was trying to get me to have pitty on him that he was about to fall over or something. lol. He had a very calm disposition though, and me and him had a very good bond... So he never tried anything rash. In no time I could just walk up to him without haltering him and pick up all 4 feet.
Before this we've had horses that wouldn't pick up their feet, and we did exactly what the others wrote to do. Don't let go. They'll usually fight you on it, and try to step away, but you still have to have hold of that foot. As soon as you let go when they do either, they are going to keep doing it; they got away with it before, and they'll want to get away with it again. As soon as they stop fighting you for a second or two, you can guide their foot back to the ground. (Don't just 'drop' their foot; it banging against the ground isn't going to help with them giving you their feet. ie: you want them to give it to you nicely, then be kind back. Makes them more willing.) Then as the others have said, just slowly increase the amount of time you hold their feet.
Now, for a horse that takes more than 'a few steps', consider having someone else hold the horse for you until they get better about picking their feet up. This limits them to only being able to take a step or two, instead of flat out 'leaving'. Then, once they get better about that, then you can simply drape the leadroap over the horses neck/back, that way if they think about stepping away, you can give them a light pull on the leadrope to remind them that you didn't say they can go yet (I also tell my horses to 'stand' when picking up their feet. Then they know that I want them to hold still. lol). It's kinda one of those things you want to make sure they get down really well before you go to the next step. Just because they do it for you once doesn't mean they are 'cured'. ;)