Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WPF仅在应用程序(非操作系统)中提高感知分辨率_Wpf_Screen Resolution - Fatal编程技术网

WPF仅在应用程序(非操作系统)中提高感知分辨率

WPF仅在应用程序(非操作系统)中提高感知分辨率,wpf,screen-resolution,Wpf,Screen Resolution,我有一个WPF,它将显示在一个非常小的设备上,屏幕很小,但操作系统的分辨率很高。分辨率无法更改(硬件限制),因此我必须“放大”我的WPF应用程序,使其在小型设备上可用 我的想法是在chrome中实现“放大/缩小”功能(其他浏览器也是如此)。例如,访问并按ctrl+。我想要一个WPF应用程序的类似效果 我在想类似于 ZoomFactor = 2 WPFApp.RenderSize.Width = WPFApp.Size.Width / ZoomFactor WPFApp.RenderSize.He

我有一个WPF,它将显示在一个非常小的设备上,屏幕很小,但操作系统的分辨率很高。分辨率无法更改(硬件限制),因此我必须“放大”我的WPF应用程序,使其在小型设备上可用

我的想法是在chrome中实现“放大/缩小”功能(其他浏览器也是如此)。例如,访问并按ctrl+。我想要一个WPF应用程序的类似效果

我在想类似于

ZoomFactor = 2
WPFApp.RenderSize.Width = WPFApp.Size.Width / ZoomFactor
WPFApp.RenderSize.Height = WPFApp.Size.Height / ZoomFactor 
这将“理论上”使WPF认为它是为大屏幕渲染的,但是应用程序实际上仍然具有两倍的不动产(ZoomFactor)

然后,我认为ScaleTransform可以缩放呈现的内容以填充整个应用程序

WFPApp.RenderedContent.ScaleTransformX = ZoomFactor
WPFApp.RenderedContent.ScaleTransformY = ZoomFactor
这还允许应用程序以任何方式调整大小,ZoomFactor仍将应用于内容

我对WPF比较陌生,所以可能有一种开箱即用的方法,但如果没有,我将如何实现这一点

尝试使用布局变换和比例变换

工作得很有魅力。这是我用来生成刻度的逻辑

public static double GetElementScale(Size designSize, Size currentSize)
{
    var ratioY = currentSize.Height / designSize.Height;
    var ratioX =  currentSize.Width / designSize.Width;

    return Math.Max(ratioX, ratioY);
}
然后,在我的页面上有两个缩放属性,我使用了以下内容

<controls:MPage.LayoutTransform>
    <ScaleTransform  ScaleY="{Binding Path=ScaleY, RelativeSource={RelativeSource AncestorType={x:Type controls:MPage}}}" ScaleX="{Binding Path=ScaleX, RelativeSource={RelativeSource AncestorType={x:Type controls:MPage}}}" />
</controls:MPage.LayoutTransform>