Why are X-rays used in crystallography?

Can any other wavelength of electromagnetic radiation be used? Why can't gamma radiation be used?

There are a few reasons, but the most direct answer is that the wavelength of X-ray photons is on the order of the distance between atomic nuclei in solids, e.g. ~ 4 ångströms (bonds are roughly 1.5-2.5 Å). You can think of it like the waves fit nice and snugly between the atoms and "fill" the crystal and thereby give us information about where the "cavities" are, and thus by reciprocal analysis (inverse Fourier transform) we can determine where the "rigid" stuff is (the atoms).

Other kinds of incident radiation are used e.g. neutron beams (for crystallography) and even electron beams (for surface spectroscopy), but X-rays are a more readily available source of radiation. In other words, it's easier/cheaper to produce X-rays than a beam of pure neutrons.

Gamma rays are about 100 times smaller in wavelength than X-rays (so instead of 4 Å, something like 0.04 Å, and so they generally penetrate through any solid material and don't produce a clear diffraction pattern like X-rays. Also if I'm not mistaken, it is much more difficult to produce gamma rays.

It's important to realize that diffraction is not the same as reflection and refraction. The latter two are surface phenomena - diffraction is a bulk phenomena completely unrelated to surfaces.

Electrons interact strongly with the surface of solids not only because of their charge but their energetic wavelength - gamma rays interact very weakly with a bulk crystal and go right through it. X-rays and neutrons (bearing no charge) are in the "happy medium" and produce a sufficient interaction with crystals as to give information about the arrangement of particles.

Picture taken from wikipedia's X-ray article:

More useful info in Economou's book "The Physics of Solids" can be found.

• To be more specific, the most common X-ray wavelengths used in crystallography are 0.7 and 1.5Å. – Ivan Neretin Mar 2 '16 at 13:00
• Indeed -- those are the wavelengths that correspond to atomic bonds. X-rays are categorically described in the range 0.1 - 100A, so crystallography is a pretty specific application of x-ray energy. – khaverim Mar 2 '16 at 14:17