I posted an answer for this on Physics SE recently, but have also just had a query on this from another Astronomy SE answer, so I am adding this here for completness.
You can approximate the plane of the galaxy as a disk made up of stars and gas, with a density $\rho(|z|)$, that decreases with absolute distance $|z|$ from the plane.
If then assume that the Sun is close enough to $z=0$ and that the radial variation in $\rho$ was negligible enough to treat the disk as an infinite plane (this is not bad, the amplitude of the Sun's motion is only about 10% of the radial scale length of the disk density), then you could construct a little cylinder through the plane, with one face at $z=0$, where $g=0$, and use Gauss's law for gravity to estimate the gravitational acceleration at height $z$.
$$ g(z) \simeq -4\pi G \int_0^{z} \rho(z)\ dz$$
This is effectively decomposing the Sun's orbit into a radial/tangential orbit plus a vertical motion, which I treat here.
Now $\rho(z)$ approximates to an exponentially decaying function with a scale height of maybe 200-300 pc. If we are closer to $z=0$ than that, then the density is roughly a constant $\rho_0$. Putting this into the equation above, we see that
$$g(z) =-4\pi G\rho_0 z.$$
But this is just simple harmonic motion with an angular frequency $\sqrt{4\pi G\rho_0}$.
The density of the disk near the Sun has been estimated to be 0.076 solar mass per cubic parsec (Creze et al. 1998). Using this value, we get an approximate predicted oscillation period up and down through the disk plane of 95 million years. This is pretty close to the accepted value of 70 million years considering the approximations that have been made.
In the context of the question you ask I should add that the mass density I quote above is actually derived from the positions and motions of stars in the solar neighbourhood. As the paper I referenced discusses, the value they obtain is close to that obtained by counting stars and adding the contributions of gas and dust. There is actually little evidence for dark matter in the disk from these measurements.
This result is entirely consistent with the idea of a dark matter distribution that is 10x the visible mass but roughly spherically symmetric, and which accounts for the Milky Way rotation curve. Not much of this dark matter is in the disk.
Finally, the picture is not quite right. The Sun completes only about 3 vertical oscillations for every orbit around the Galactic centre.