Ludwig Wilhelm, Duke in Bavaria