For many years, the walls around the Navy Yard reflected the reality of the neighborhood: The safe place to be was on the inside.

On Monday, people who live and work in the community just south of the U.S. Capitol found it striking that such violence would happen within the Navy Yard, long considered an island in a part of the city once known for high crime, strip clubs and empty lots.

While not gone entirely, that edge has softened over the past decade as the neighborhood has undergone a radical transformation, with upscale townhomes springing up plus the opening of Nationals Park and water parks where families with young children flock in warm weather to swim and to dance at concerts.

Those changes made the police activity that followed the shooting deaths of 12 people at the hands of a gunman feel all the more jarring to those who live there, as though time were moving backward.

Instead of enjoying the neighborhood’s amenities and spending time with one another Monday, many residents were holed up inside with fear in the air.

“For the first time, you can hear a pin drop,” Norma Verona said.

Verona, who has lived with her husband and two daughters near the Navy Yard for about four years, said she and her neighbors have bonded over their decision to take a chance on an area remaking itself after rougher years.

“We are very united because we were willing to take a risk,” Verona said, “so we have each other’s back.”

Jacqueline Dupree, who runs a popular blog called about development around the Navy Yard, keeps crime data. She said that to her knowledge a homicide has not occurred near the Navy Yard in almost a decade.

But the progress felt obscured by the shootings Monday. The mood, Verona said, was “gloomy.”

On Monday, M Street SE, the main road that runs alongside the Navy Yard complex, was shut to most traffic, becoming a kind of pedestrian mall for police, journalists and workers waiting for news from the inside. M Street is lined with new eateries and other emblems of gentrification, including a new green-designed water park that turns into an ice-skating rink in winter, as well as a place to plug in electric cars and signs for a new bocce league.

Kurt Hansen, 43, knows the neighborhood because he is a D.C. police officer and has worked in nearby Anacostia for years. He now is there every day because his daughter attends Tyler Elementary School. He takes her after school to Canal Park, a splash park near the Navy Yard Metro station, and every Friday night in summer they come to the Yards Park — a larger water park next to the Navy Yard, directly on the Anacostia River — for concerts.

In the past “it always seemed like if any place is safe, it’s the Navy Yard, because it’s locked down,” he said.

Recently, he has surprised friends from around the region when he brings them to see the neighborhood. “They say: ‘We had no idea this is D.C.’ And I’m like: ‘This is the way it has changed. This is what it is.’ ”

But on Monday, Hansen sprang into a different mode. He was dropping off his daughter at Tyler when the shooting and lockdown happened. He decided on his off day to position himself at the school’s door. “No gunman shall pass,” he said.

The building where the shooting happened played a key role in the neighborhood’s transformation, said Dupree, who is a Washington Post employee. The decision in the late 1990s for the Naval Sea Systems Command to bring the building and more than 4,000 new employees to the neighborhood was one of its key milestones — along with the rebuilding of public housing there and the creation of the ballpark.

The Navy Yard area, which runs along the southern border of the residential Capitol Hill neighborhood, is an unusual mix. Between the Navy Yard, the Transportation Department building and the Marine base a block up, uniforms of all kinds are common. On weekends there are also clusters of baseball fans walking from the subway to the stadium. In the midst are families and others snapping up brightly colored new rowhouses, as well as an ever-growing number of people who come to eat at new restaurants and bars opening on Barracks Row, or Eighth Street SE, which runs from Eastern Market to the Navy Yard.

It’s clearly still a neighborhood in transition. Cranes and builders are a common sight, as are lots waiting to be built upon.

On Monday morning, Navy employees coming in and out of the L Street convenience store at Seventh Street SE, one block from the Navy Yard entrance, said the neighborhood still feels somewhat edgy. “A lot of people walk around here looking half-wound,” one woman said.

The store’s owner, Eun Park, said that it was robbed last month and that she had mixed feelings about neighborhood officials asking her not to put bars on a large window. She recently had put the window where a brick wall used to be because locals said they prefer that look.

“I like it here, but it’s still dangerous,” she said.

Karen Mills grew up in the Navy Yard area in the late ’60s and is now a pastor for a church at Fourth and I streets SE. She said the neighborhood bonded as residents sought to make the area safer but also because they were more similar in some ways — more African American and less wealthy, and everyone had lived there for a long time. “Even with the crime, everyone stuck together.”

But crime isn’t unfamiliar to people in that neighborhood.

On Monday, while Hansen guarded the door at Tyler, other parents were confined to the building all day because of the lockdown. While they were inside, someone broke into one mother’s car to steal her purse and phone.