Tā yǐwéi méi rén zhīdào, méi xiǎngdào dōngchuāngshìfā.
He thought no one knew, but then the whole thing came to light.
Tips
history
From the Yuan play 《东窗事犯》 and later Ming geography 《西湖游览志馀》: Song-dynasty traitor Qin Hui plotted the murder of general Yue Fei under the east window of his home with his wife. After dying, Qin Hui supposedly sent a message from the underworld: 东窗事发矣 - 'the east window affair has come out.' The idiom has meant 'the plot is exposed' ever since.
register
Always about wrongdoing - crimes, corruption, affairs, fraud. Strongly negative (from the criminal's perspective). Natural in news reports and narratives, common in crime and political contexts.