I have a WPF application, that doesn't care of device DPI, but instead is autmatically scaled to fill the screen (but keeping its aspect ratio).
I scale it by changing the ScaleX and ScaleY properties of the transform of the outer most WPF container.
In this case, do I still have to get the monitor’s DPI or can I just use "1.0" as "pixelsPerDip" in the function call of FormattedText?
The reason I ask is, that I try to remove all warnings from my code, and I get a warning, that the override without "pixelsPerDip" is obsolete.
I ran into this same issue. You can get the
DpiScale
like this:var dpiInfo = VisualTreeHelper.GetDpi(visual);
In this case you could pass in your root element as the visual.
Now you can call
FormattedText
, etc., and pass indpiInfo.PixelsPerDip
.I hope this helps.