Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the DPI in WPF?

Tags:

dpi

wpf

How can I get the DPI in WPF?

like image 381
tom greene Avatar asked Dec 17 '09 01:12

tom greene


1 Answers

https://docs.microsoft.com/en-us/archive/blogs/jaimer/getting-system-dpi-in-wpf-app seems to work

PresentationSource source = PresentationSource.FromVisual(this);  double dpiX, dpiY; if (source != null) {     dpiX = 96.0 * source.CompositionTarget.TransformToDevice.M11;     dpiY = 96.0 * source.CompositionTarget.TransformToDevice.M22; } 
like image 72
Ana Betts Avatar answered Sep 22 '22 07:09

Ana Betts