As the Obamas, the Bushes and the Bidens stood to sing at the memorial service for the Dallas police shooting victims, they were all somber and solemn - except one.

Holding hands with his wife, Laura Bush, and First Lady, Michelle Obama, former president George W Bush swung their hands, swayed back and forth and smiled widely.

On the other side of the podium were Dallas mayor Mike Rawlings and Dallas police chief David Brown, a man who has lost his partner, brother and son to violence in the city.

The politicians and police chiefs were gathered for a memorial service for the five Dallas police officers who were killed and seven who were injured when 25-year-old Micah Xavier Johnson opened fire during a peaceful protest.

The protest had followed the killings of two black men, Alton Sterling and Philando Castile, by law enforcement.

At the memorial, as the choir behind current and former presidents at the Morton H Meuerson Symphony Center sang the American Civil War-era song, "The Battle Hymn of the Republic", only Mr Bush and his wife sang along as the rest of the line remained quiet.

At one point, Michelle Obama smiled and leaned over, whispering something into his ear as Mr Obama looked on.

(AP (AP)

At the end of the song, Mr Bush held up the two women’s hands and grinned widely, while the Obamas maintained respectfully solemn faces.

If the former president lacked composure during the song, Mr Bush regained a sense of his surroundings when he gave his speech.

“Too often we judge other groups by their worst examples while judging ourselves by our best intentions,” he said to loud applause.

“None of us were prepared or could be prepared for such an ambush with malice,” added Mr Bush. “The shock of this evil has not faded. At times it seems the forces pulling us apart are stronger than the forces binding us together.”