Did Samson receive his strength strictly from his hair? Why did he no longer possess his physical power after Delilah gave him a trim?
First, let us do a brief synopsis of the life of Samson before delving into whether his superhuman strength came from his hair or not. His parents were initially childless due to his mother's barrenness (Judges 13:2). God healed her for the express purpose that she bare a son to begin to free the Israelites from Philistine domination (verses 1, 5).
Interestingly, not only was she commanded to raise Samson as a Nazarite (Judges 13:5, 7), she was also instructed on what food and drink to avoid during her pregnancy (verses 4, 7, 14). One of the major requirements of those under a Nazarite vow was that they not cut any hair off of their head.
God blessed Samson as he was growing up and taking his vow seriously by leaving his hair uncut (Judges 13:24 - 25). As a man, He used his unusual strength to wage a one-man war against the tyranny of the Philistines. He also served twenty years as one of Israel's Judges (1085 to 1065 B.C.).
We now come to the well-known incident referred to in your question. The Philistines, who were frustrated and angered that they were unable to counteract Samson's strength, decide to utilize the services of a harlot named Delilah. Five Philistine leaders agree to pay her a hefty sum of money to find out how they could take down this mighty warrior (Judges 16:5).
And he (Samson) told her (Delilah) all his heart, and said to her, "A razor has not come upon my hair, for I am a Nazarite to God from my mother's womb. If I am shaven, then my strength will go from me . . .
And she made him sleep upon her knees. And she called for a man, and she caused him to shave off the seven locks of his head . . . (Judges 16:17, 19, HBFV).
After Delilah arranged for Samson to receive the only haircut he would ever have, he became as weak as other men were. While it certainly seems that he got his strength strictly from his hair, further study reveals this is not the case.
The true source of power
With his locks gone, the Philistines quickly rushed in to seize Samson. When he woke, he assumed he could, as he had done so many times in the past, use his power to save himself. He did not know, however, "that the Lord had departed from him" (Judges 16:20). He was immediately seized, tortured, and made a prisoner (Judges 16:20 - 21). The clear scriptural indication is that it was God's presence that gave him his miraculous abilities.
If we assume the uncut hair of a Nazarite, of itself, provides miraculous physical prowess, we then should expect others under the same criteria to have the same abilities. The Bible, however, does not support this assumption.
The hair of Samson begins to grow back after he is taken prisoner by the Philistines (Judges 16:22). He also begins to repent of what he had done. While resting after being forced to entertain a large group of Philistines celebrating their victory over him, he utters what would become his last words.
And Samson called to the Lord and said, "O, Lord God, remember me, I pray You, AND STRENGTHEN ME, I pray You, only this once, O God, so that I may be at once avenged of the Philistines for my two eyes" (Judges 16:28)
This prayer would not be necessary if his hair, which had grown back, was of itself the source of his strength. Samson understood that his physical power came from the God he served and therefore asked him directly for one last chance to use it to fulfill his will. Gill's Exposition of the Entire Bible states the following regarding this prayer.
". . . and it was a prayer of faith, as appears by its being heard, accepted, and answered; and shows that his strength did not come with his hair, but was owing to the immediate communication of it from the Lord"
In closing, Samson was not born with some genetic defect or mutation that gave his hair the ability to impart superhuman strength. He was consecrated to God's service through the Nazarite vow.
When Samson sinned and broke his vow (Numbers 6:5), he cut himself off from the true source which made him strong. It was only after pain, suffering and humiliation that he came to his senses and asked, for his final act, that his gift be restored to him. His sincere prayer was honored and he died doing God's will.