I'm not sure if this is a bug, or just something that I'm missing, but there is definitively something weird with how Revit dockable pages display on systems that implement video scaling, namely windows 8.1 on retina displays.
Let me first start by explaining what I mean by video scaling. Windows has a feature under display settings that allows you to "scale" objects on your display. This is different from the use of resolution. Here's an illustration of what I'm talking about:
The dockable page in question is basically divided up into two even columns down the center. When the Windows video scaling is set to anything other than 100%, it throws off the coordination between the grid and the host page width. Sorry for having to blur out the controls, but here is a sample of what my dockable page looks like (cutting off about 50% on right hand side):
I went through the normal process of handling this through traditional WPF windows means thinking that I'd be out of the woods, but nope. My dockable page object is surrounded by one master grid, but for some reason on systems with video scaling active, this grid does not know how large it is supposed to be. The whacky result is what you see above with the cut-off issues.
The "traditional" code that should have worked, but did not is shown below. It gets the video scaling from the Matrix object and then applies that value to the ScaleTransform of my MasterGrid which is of course the base grid at the top level of the page layout.
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
Matrix m = PresentationSource.FromVisual(Application.Current.MainWindow).CompositionTarget.TransformToDevice;
double dx = m.M11;
double dy = m.M22;
ScaleTransform s = (ScaleTransform)MasterGrid.LayoutTransform;
s.ScaleX = 1 / dx;
s.ScaleY = 1 / dy;
}
What I ended up having to do was first get the scaling values from the matrix object (similar to above) and then use the SizeChanged event on my Revit dockable page to adjust the width and height to match the size of the page object.
The code that ended up working for adjusting the host grid object size with scaling is shown here.
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
Matrix m = PresentationSource.FromVisual(this).CompositionTarget.TransformToDevice;
double dx = m.M11;
double dy = m.M22;
GridMain.Width = this.Width / dx;
GridMain.Height = this.Height / dy;
}
The code above gets the current Windows video scaling in the same way, but the difference is that instead of applying scaling, we're just calculating the corrected widths and heights for the form. Here's how the page looks after the updates (slightly less blur):
I'm curious if anyone else has run into this and if so, how did you deal with it?