The paper proposes a robust and area-efficient way of designing window discriminators for photon-counting pixel detectors. For that, an all-digital window discriminator is proposed. It is event-driven and does not rely on any external or internal timing references, which makes it possible to use it over a wide range of specifications. In addition, it provides an overall area efficient implementation of the digital electronics in photon-counting pixel detectors. The transistor-level implementation of the circuit is presented with its circuit area and timing performance.