It seems that this behavior happens when a root visual is ScrollViewer. (When I wrap the ScrollViewer with a Grid, it works fine)
sender, StartupEventArgs e)
ScrollViewer scrollViewer =
.RootVisual = scrollViewer;
I am unable to attach a zip file with a sample project to this post.