STUTTGART, Germany -- U.S. Air Forces Europe said troops holding "Make America Great Again" hats during President Donald Trump's visit Thursday to Ramstein Air Base were not in violation of military rules that prohibit taking part in partisan activities while in uniform.

"There is no rule against Airmen bringing personal items to be signed by the president," USAFE said in a statement.

More than 200 airmen greeted Trump on Thursday at a Ramstein Air Base aircraft hangar, where the president and first lady Melania Trump were greeted with cheers.

Trump posed for photos, shook hands and signed autographs with airmen during a scene that resembled photo-op visits of former commanders-in-chief in years past. But the public display by some uniformed troops, who held red "Make America Great Again" hats synonymous with Trump's 2016 presidential campaign, prompted widespread criticism on social media. An Air Force captain carrying a Trump banner also was scrutinized.

"There are myriad reasons for both a Department of Defense and an Army Regulation against military personnel participating in or showing allegiance to ANY political party while in uniform," wrote retired Army Lt. Gen. Mark Hertling on Twitter Thursday. "Good commanders enforce; good NCOs jerk a knot in the (expletive) of those who violate."

Pam Keith, a former Navy judge advocate general and recent Democratic candidate for Congress in Florida, also opined. "I can tell you that engaging in partisan political activity such as flying a Trump flag or wearing a MAGA hat, while in uniform is a violation of the Uniform Code of Military Justice and its implementing regs," Keith said on Twitter.

USAFE said troops held the hats for signing, but did not wear them while in uniform.

A Defense Department directive states that personnel must refrain from engaging in partisan political activities when in uniform and "should avoid the inference that their political activities imply or appear to imply DoD sponsorship, approval, or endorsement of a political candidate, campaign, or cause."

However, USAFE said it is unaware of any actions during the event that amounted to a violation of regulations.

"Any time the commander in chief offers the opportunity to meet with Airmen, such as this official holiday visit by the President and First Lady, Airmen are welcome to participate. No policy violations have been brought to our attention at this time," USAFE said.

On social media, there also were defenders of the troops with Trump hats and signs, who argued there is nothing inherently partisan about the "Make America Great Again" slogan.

"Asking your Commander-in-Chief to sign a MAGA hat is NOT a political campaign action and is not illegal," tweeted Sebastian Gorka, an outspoken former Trump administration official.

Still, during the event at Ramstein, there were signs of concern among command officials. Before the president's arrival, the Air Force captain holding the Trump flag was directed to put it away by an official with the 86th Airlift Wing, but the captain pulled it back out upon Trump's arrival.

The captain presented the banner to Trump, who autographed it.