  If the $X(3872)$ is a weakly bound charm-meson molecule, it can be produced
by the creation of $D^{*0} \bar{D}^0$ or $D^{0} \bar{D}^{*0}$ at short
distances followed by the formation of the bound state from the charm-meson
pairs. It can also be produced by the creation of $D^{*} \bar{D}^*$ at short
distances followed by the rescattering of the charm mesons into $X \pi$. We use
results of a previous isospin analysis of $B$ meson decays into $K D^{(*)} \bar
D^{(*)}$ to estimate the short-distance amplitudes for creating $D^* \bar D^*$.
We use an effective field theory for charm mesons and pions called XEFT to
calculate the amplitudes for rescattering of $D^{*} \bar{D}^*$ into $X \pi$
with small relative momentum. The $X\pi$ invariant mass distribution is
predicted to have a narrow peak near the $D^{*} \bar{D}^*$ threshold from a
charm-meson triangle singularity. We estimate the branching fractions into the
peak from the triangle singularity for the decays $B^0 \to K^+ X \pi^-$ and
$B^+ \to K^0 X \pi^+$.
