好的,类似以下内容将解决此问题:
Public Shared Function GetDpiAdjustedMargins(ByVal WindowHandle As IntPtr, ByVal Left As Integer, ByVal Right As Integer, ByVal Top As Integer, ByVal Bottom As Integer) As Margins
'
Dim Graphics As System.Drawing.Graphics = System.Drawing.Graphics.FromHwnd(WindowHandle)
Dim DesktopDPIx As Single = Graphics.DpiX
Dim DesktopDPIy As Single = Graphics.DpiY
Dim Margins As Margins = New Margins
Margins.Left = Left * (DesktopDPIx / 96)
Margins.Right = Right * (DesktopDPIx / 96)
Margins.Top = Top * (DesktopDPIx / 96)
Margins.Bottom = Bottom * (DesktopDPIx / 96)
Return Margins
'
End Function
资料来源:C# 2008 中的 Pro WPF,作者:Matthew MacDonald