DockablePane & font size != 100%

DockablePane & font size != 100%

FRFR1426
Collaborator Collaborator
792 Views
1 Reply
Message 1 of 2

DockablePane & font size != 100%

FRFR1426
Collaborator
Collaborator

I've made a dockable pane which hosts a WPF user control. It works OK, but if I go to Control Panel > Appearance and Personalization > Display and I change the size of the font for the entire system to 150%:

 

custom-sizing-options-windows-10.jpg

 

The WPF user control children do not resize themselves properly. I've got this result:

 

150.png

 

Note that the Textbox is truncated on the right. The width of the root grid is not correctly computed.

 

 

 

At 100%, it's OK.

100.png

 

There is a similar problem described here: https://bimdev.blogspot.fr/2014/11/revit-dockable-pane-failures-with.html but the solution presented does not work for me on Windows 10 - Revit 2016/2017

 

 

 

 

 

 

 

 

Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr
0 Likes
Accepted solutions (1)
793 Views
1 Reply
Reply (1)
Message 2 of 2

FRFR1426
Collaborator
Collaborator
Accepted solution

I've found a solution. We can compensate by adding a margin to the root grid (grMain):

 

void UserControl_OnSizeChanged(object sender, SizeChangedEventArgs e)
{
    HandleTextScaling();
}
void HandleTextScaling() { PresentationSource source = PresentationSource.FromVisual(this); Debug.Assert(source != null, "source != null"); CompositionTarget target = source.CompositionTarget; Debug.Assert(target != null, "target != null"); Matrix m = target.TransformToDevice; double scale1 = m.M11; double scale2 = scale1 - 1; grMain.Margin = new Thickness(0, 0, scale2 * ActualWidth / scale1, scale2 * ActualHeight / scale1); }
Maxence DELANNOY
Manager
Add-ins development for Autodesk software products
http://wiip.fr