简体   繁体   English

缩放WPF窗口

[英]Scaling the WPF window

In kinect the co ordinates of the main window starts from the centre(view area) of it. 相对于此,主窗口的坐标从其中心(视图区域)开始。
I want to scale this window to the specified size like 640*480. 我想将此窗口缩放为指定的大小,例如640 * 480。
I am using C# for this. 我为此使用C#。
Thank you in advance. 先感谢您。

Note : I don't want to use any libraries for this. 注意:我不想为此使用任何库。

There are a couple of options: 有两种选择:

  • use ViewBox 使用ViewBox
  • use a Layout-ScaleTransform 使用Layout-ScaleTransform
  • use a Render-ScaleTransform 使用Render-ScaleTransform

As I don't know exactly what you want I cannot advise you on what to use but if I get the hint with the "centre" right I would start by using the layout-scaletransform. 因为我不确切知道您想要什么,所以我无法为您提供使用建议,但是如果我得到“中心”提示,我将从使用layout-scaletransform开始。

Use a ScaleTransform and put it in the LayoutTransform of your Window. 使用ScaleTransform并将其放在窗口的LayoutTransform中。 You'll have to calculate the ScaleX & ScaleY based on your current X & Y-value because it works with percentages. 您必须根据当前的X和Y值计算ScaleX和ScaleY,因为它可以使用百分比。 Standard values for ScaleX & ScaleY will be 1 (= 100%) ScaleX和ScaleY的标准值为1(= 100%)

If you want to know the difference between RenderTransform & LayoutTransform read this article. 如果你想知道的RenderTransform和LayoutTransform之间的区别阅读文章。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM