Depending on whether you target .NET 5 or an earlier version, you should either set the TargetFramework
to net5.0-windows10.0. * or install the Microsoft.Windows.SDK.Contracts
NuGet package as described here .
You can then use the Windows.UI.ViewManagement.UISettings.TextScaleFactor
property:
double factor = new UISettings().TextScaleFactor;
I've found a way to retrieve the Text Scaling Factor , without installing any Nuget packages. The idea is to obtain the value directly from the registry.
var userKey = Microsoft.Win32.Registry.CurrentUser;
var softKey = userKey.OpenSubKey("Software");
var micKey = softKey.OpenSubKey("Microsoft");
var accKey = micKey.OpenSubKey("Accessibility");
var factor = accKey.GetValue("TextScaleFactor");`
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.