In materials with inhomogeneity, macroscopic properties depend not only on local electronic or magnetic properties but also on the way inhomogeneity is spatially distributed. Controlling this spatial pattern may therefore create new functionality. Modern X-ray sources provide the means for mapping out the spatial distribution of, e.g., magnetic domains or coexisting phases as well as for tracking the evolution of spatial patterns in time. Such experiments enable us to develop strategies for controlling disorder. I will show examples for coexisting phases and complex magnetic patterns and will discuss relevant length and time scales for future experiments.