In particle image velocimetry (PIV) a temporally separated image pair of a gas or liquid seeded with small particles is recorded and analysed in order to measure fluid flows therein. We investigate a variational approach to cross-correlation, a robust and well-established method to determine displacement vectors from the image data. A "soft" Gaussian window function replaces the usual rectangular correlation frame. We propose a criterion to adapt the window size and shape that directly formulates the goal to minimise the displacement estimation error. In order to measure motion and adapt the window shapes at the same time we combine both sub-problems into a bi-level optimisation problem and solve it via continuous multiscale methods. Experiments with synthetic and real PIV data demonstrate the ability of our approach to solve the formulated problem. Moreover window adaptation yields significantly improved results.