dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.08k stars 1.17k forks source link

FontSize is no longer inherited for some controls #10038

Closed aquinn39 closed 18 hours ago

aquinn39 commented 1 week ago

Description

Previously in .NET 8 and below, the FontSize property of controls would be inherited from its parent. For example, if you add a Button as a child of a Window and set the font size of the window, the Button will inherit the font size of the Window. In .NET 9, with the fluent themes enabled, some controls such as the CheckBox and Button, no longer inherit their font size from their parent, while the TextBlock by iteself, still does.

The FontSize on the Window below is set to 40 but the ComboBox and CheckBox do not care: Image

Reproduction Steps

  1. Create a new WPF project and set it to use .NET 9 RC 2
  2. Enable fluent themes in the project as described here: https://github.com/dotnet/core/blob/main/release-notes/9.0/preview/preview4/wpf.md#support-for-windows-11-theming
  3. Create a new window
  4. Add a grid to this Window and add box a CheckBox and TextBlock to this Window
  5. Change the Window's FontSize
  6. Observe that the FontSize of the TextBlock matches the Window's but the CheckBox's FontSize does not

Expected behavior

FontSize should inherit from its parent.

Actual behavior

FontSize seems to be stuck at whatever is provided by the control template.

Regression?

Yes, works in .NET 8 and .NET Framework.

Known Workarounds

None that I know of so far. If anyone knows any, would love to hear them as this is a problem for me.

Impact

No response

Configuration

.NET 9, AnyCPU, Windows 11 build 22631.4037.

Other information

No response

aquinn39 commented 5 days ago

@dipeshmsft Are there other fixes which have been made since RC2 do you know? I've found numerous other bugs with the new themes such as crashing in high contrast so wondering if there are some fixes which didn't make it to RC2.

dipeshmsft commented 5 days ago

@aquinn39 first of all I confused with the Font scaling issue, while fixing that I came across this and started working on this, but there were some blockers to this.

There are a few PRs that are up and yet to be merged and there were a couple of bugs related to TemplateBindings that have been fixed later.

Can you raise the high contrast crash issue though, I don't think we have got into that.

Thanks for trying out the new themes and bringing the issues to us. Appreciate your efforts.

aquinn39 commented 5 days ago

@dipeshmsft https://github.com/dotnet/wpf/issues/10043

aquinn39 commented 18 hours ago

Seems to be fixed in .NET 9.