Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,12 @@ internal void FocusActiveControlInternal()
private SizeF GetParentAutoScaleFactor()
{
Control parentControl = Parent;
while (parentControl is not null and not ContainerControl)

// Traverse through parent hierarchy until we get a ContainerControl whose AutoScaleMode is not Inherit.
// AutoscaleFactor from this parent is used to scale the child controls within its hierarchy.
while (parentControl is not null
&& (parentControl is not ContainerControl containerControl
Copy link
Contributor

@Tanya-Solyanik Tanya-Solyanik Nov 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have other places with similar code walking the parent chain, don't we? Do we always skip non-container controls?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AutoscaleFactor is property on ContainerControl . So, we have to traverse parent chain until we get the right scale factor for its children. Also, ContainerControl gets OnFonChanged events to scale the children. Non-Container controls that receive OnFontChanged does not scale control but just set the Font.

|| containerControl.AutoScaleMode == AutoScaleMode.Inherit))
{
parentControl = parentControl.Parent;
}
Expand Down