diff --git a/src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs b/src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs index c1ef9476db..08af820fe1 100644 --- a/src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs +++ b/src/Avalonia.Controls/Remote/Server/RemoteServerTopLevelImpl.cs @@ -85,7 +85,7 @@ namespace Avalonia.Controls.Remote.Server } } - protected void SetDpi(Vector dpi) + public void SetDpi(Vector dpi) { _dpi = dpi; RenderIfNeeded(); diff --git a/src/Avalonia.DesignerSupport/DesignWindowLoader.cs b/src/Avalonia.DesignerSupport/DesignWindowLoader.cs index 6dca479d38..853d8c3dbb 100644 --- a/src/Avalonia.DesignerSupport/DesignWindowLoader.cs +++ b/src/Avalonia.DesignerSupport/DesignWindowLoader.cs @@ -5,6 +5,7 @@ using System.Reflection; using System.Text; using Avalonia.Controls; using Avalonia.Controls.Platform; +using Avalonia.Controls.Remote.Server; using Avalonia.Markup.Xaml; using Avalonia.Styling; @@ -12,7 +13,7 @@ namespace Avalonia.DesignerSupport { public class DesignWindowLoader { - public static Window LoadDesignerWindow(string xaml, string assemblyPath) + public static Window LoadDesignerWindow(string xaml, string assemblyPath, Vector dpi) { Window window; Control control; @@ -69,6 +70,9 @@ namespace Avalonia.DesignerSupport if (!window.IsSet(Window.SizeToContentProperty)) window.SizeToContent = SizeToContent.WidthAndHeight; } + + (window.PlatformImpl as RemoteServerTopLevelImpl).SetDpi(dpi); + window.Show(); Design.ApplyDesignModeProperties(window, control); return window; diff --git a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs index 4536748836..4cd14d56d1 100644 --- a/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs +++ b/src/Avalonia.DesignerSupport/Remote/RemoteDesignerEntryPoint.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Net; using System.Reflection; @@ -191,7 +191,8 @@ namespace Avalonia.DesignerSupport.Remote s_currentWindow = null; try { - s_currentWindow = DesignWindowLoader.LoadDesignerWindow(xaml.Xaml, xaml.AssemblyPath); + var dpi = s_viewportAllocatedMessage != null ? new Vector(s_viewportAllocatedMessage.DpiX, s_viewportAllocatedMessage.DpiY) : new Vector(96, 96); + s_currentWindow = DesignWindowLoader.LoadDesignerWindow(xaml.Xaml, xaml.AssemblyPath, dpi); s_transport.Send(new UpdateXamlResultMessage(){Handle = s_currentWindow.PlatformImpl?.Handle?.Handle.ToString()}); } catch (Exception e)