Suppose $X$ and $Y$ are two random variables defined on a probability space $(\Omega, \mathcal{F},P)$ with joint density function $f_{X,Y}$. For any $B \in \mathcal{B}(\mathbb{R})$, why is it that $ \int_\mathbb{R} y \left( \int_\mathbb{R} I_B(x) f_{X,Y}(x,y) \,dx \right) \, dy = \int_\Omega Y I_{X^{-1}(B)} \, dP \quad ? $ Note: This is one step needed in my attempt to prove that the elementary definition and theorectical definition of $E(Y|X)$ agree a.e. after applying Fubini's Theorem.
Thanks!