Visual Studio 2015中的应用扩展问题

格雷厄姆

我是Visual Studio的一名新手,但是我想创建一个相当简单的应用程序供自己在台式机上使用。我非常精通python和VBA,所以我确实有一些编码经验。尽管适应新语言令人困惑,但我认为我可以管理,这不是本文的目的。我已经看过了,但似乎看不到这个问题的明确答案。

本质上,我想知道如何使在“设计”视图中看到的内容与使用“本地计算机”选项运行应用程序时看到的内容完全相同。创建项目时,我选择了C#> Windows> Windows 8> Windows,然后为Windows 8.1选择了空白应用程序,因为这是我当前正在运行的应用程序。我的问题是我的显示器是1920x1080。当我使用xaml代码和设计视口在MainPage.xaml上进行设计时,我想出了使外观看起来更好的方法。但是,当我单击程序顶部的“本地计算机”选项运行应用程序时,情况变得很奇怪。

该应用程序可以正常打开;背景和单个元素都很好。但是,所有内容的对齐方式均已关闭。我可以做一些调整以使外观看起来更好,但是我总是遇到一个问题,即应用程序启动时,设计视图中的所有内容都无法正常运行。

我已将问题缩小到“设备”菜单,在“显示”下拉菜单下,我可以选择许多可更改设计视图的分辨率。但是,唯一的1920x1080分辨率只有140%的缩放比例,这无济于事。有什么办法可以使它达到100%缩放比例,或者还有我没有想到的另一种方法?

我正在谈论的这张图片是:

http://i.imgur.com/y0vIqRX.png

Note how the rectangle on the right move drastically when the app is run. All individual components are the right amount of pixels and such, but the background grid messes things up when it tries to scale. Pretty much I want what is in the design view is exactly represented when I go to launch it.

Thanks for all the help you can give. This editor is really confusing.

caesay

What's happening, is that the * character that you have following all of your column widths stands for weighted average (not width in pixels!!!). Since the center column has the greatest weight, the effects are most apparent there. If you don't want to re-visit your layout approach, you can do the following: Remove the * from your grid column widths, and wrap your entire grid with a Viewbox and hard-code the width of the grid:

<Viewbox>
    <Grid x:Name="backGrid" Width="364">
    ....
    </Grid>
</Viewbox>

视图框的作用是给客户端控件(网格)无限的空间,然后检查它使用了多少空间(在我的示例中为364)。然后,它将按比例缩放网格以适合可用空间(同时保持宽高比)。

综上所述,仍然应该注意,这是不鼓励您进行布局的方法。也许使用Canvas或DockPanel而不是网格来进行布局。甚至甚至可以确保将中心列中的所有控件都设置为Horizo​​ntalAlignment =“ Stretch”,以便它将填充中心列中的可用空间。

如果您想开始设计WPF布局的一些技巧,请在评论中让我知道,然后我可以发送Skype名称或其他名称。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章