public static void SetPlacement(this Window window, string placementXml) { try { WindowPlacement.SetPlacement(new WindowInteropHelper(window).Handle, placementXml); } catch (Exception ex) { Logger.Error("Exception in SetPlacement.Exception: " + ex.ToString()); } }
public static void SetPlacement(this Window window, double scalingFactor) { try { if (window == null) { return; } RECT placementRect = new RECT((int)Math.Floor(window.Left * scalingFactor), (int)Math.Floor(window.Top * scalingFactor), (int)Math.Floor((window.Left + window.ActualWidth) * scalingFactor), (int)Math.Floor((window.Top + window.ActualHeight) * scalingFactor)); WindowPlacement.SetPlacement(new WindowInteropHelper(window).Handle, placementRect); } catch (Exception ex) { Logger.Warning("Exception in SetPlacement. " + ex?.ToString()); } }