Stable luminescent metal-organic frameworks as dual-functional materials to encapsulate ln(3+) ions for white-light emission and to detect nitroaromatic explosives.