the behavior is indeed related to DPI system. In windows applications can be in one of 3 different state regarding handling of DPI settings. They can be either un-aware
, system aware
, per-monitor aware
or the awareness might not be defined (kind of fourth option).
If WinForms application DPI-awareness has not defined in code or in application manifest or by some other means, the application is by default un-aware
(Device Independent Pixel / Screen Pixel) factor is 1 no matter what DPI settings is defined in windows. When the LightningChart is created it loads some WPF libraries and because of this the DPI awareness of the application is automatically changed to the WPF default of system aware
, and the DIP-PX
factor is changed to that defined by windows settings. After the chart is removed, the DPI-awareness is returned to original.
To counter this behaviour you must manually define the DPI-awareness of the application so that the WPF-libraries default setting will not affect the program. Note that the DPI-awareness does not have to be defined to System aware
or per-monitor aware
, but it can also be forced to un-aware
to keep the default WinForms functionality.
Probably the easiest way to set the DPI awareness is by modifying (or adding) the application manifest and setting dpiAware
to wished value, like in the following partial sample.
Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" a xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity version="126.96.36.199" name="MyApplication.app"/>
More information about the DPI awareness can be found from MSDN https://msdn.microsoft.com/en-us/librar ... 85%29.aspx
and about application manifests from https://msdn.microsoft.com/en-us/librar ... 85%29.aspx