private void OnSourceInitialized(object sender, EventArgs e) {
_source = (HwndSource)PresentationSource.FromVisual(this);
if (_source?.CompositionTarget == null) return;
// calculate the DPI used by WPF; this is the same as the system DPI
var matrix = _source.CompositionTarget.TransformToDevice;
DpiInformation = new DpiInformation(96D * matrix.M11, 96D * matrix.M22);
if (!_isPerMonitorDpiAware) return;
_source.AddHook(WndProc);
RefreshMonitorDpi();
}