WPF 窗口在运行时挤压

发布于 2024-10-06 02:28:50 字数 1217 浏览 0 评论 0原文

我在 Visual Studio 2010 中设计了一个 WPF 窗口,其中包含多个控件。该窗口被设置为程序启动的默认窗口。该窗口的大小足以让所有控件正确安装。

当我执行程序时,由于某种原因,窗口开始时比设计器中显示的尺寸小得多,并且控件不适合。如何解决这个问题?

窗口打开代码如下:

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
Title="Main"  mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="548" d:DesignWidth="924" SizeToContent="WidthAndHeight" xmlns:my="clr-namespace:ElanceTracker" WindowStartupLocation="CenterScreen" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:lc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol" xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon" xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars" xmlns:dxn="http://schemas.devexpress.com/winfx/2008/xaml/navbar" xmlns:dxca="http://schemas.devexpress.com/winfx/2008/xaml/carousel" xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts">

I've designed a WPF window in Visual Studio 2010 with several controls in it. The window is set as default for the program startup. The size of this window is sufficient for all controls to fit properly.

When I execute the program, for some reason the window starts much smaller than the size shown in designer, and controls do not fit. How to troubleshoot this problem?

The window opening code is as follows:

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid" 
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
Title="Main"  mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" d:DesignHeight="548" d:DesignWidth="924" SizeToContent="WidthAndHeight" xmlns:my="clr-namespace:ElanceTracker" WindowStartupLocation="CenterScreen" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors" xmlns:lc="http://schemas.devexpress.com/winfx/2008/xaml/layoutcontrol" xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon" xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars" xmlns:dxn="http://schemas.devexpress.com/winfx/2008/xaml/navbar" xmlns:dxca="http://schemas.devexpress.com/winfx/2008/xaml/carousel" xmlns:dxc="http://schemas.devexpress.com/winfx/2008/xaml/charts">

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

雨落□心尘 2024-10-13 02:28:50

尝试分别更改高度和宽度的 DesignHeight 和 DesignWidth,并将 SizeToContent 设置为 None。

Try changing DesignHeight and DesignWidth for Height and Width respectively, and also, set SizeToContent to None.

月寒剑心 2024-10-13 02:28:50

您使用了错误的属性。 DesignWidth 和 DesignHeight 仅设置设计时尺寸。您需要宽度和高度。

You are using the wrong attributes. DesignWidth and DesignHeight only set the design time size. You want Width and Height.

韵柒 2024-10-13 02:28:50

这个bug在最新的Visual Studio中仍然存在。
我总是将窗口设计得宽 16 像素、高 16 像素,以便在运行时获得正确的尺寸。

This bug still exist in the newest Visual Studio.
I always design my windows 16 pixels wider and 16 pixels higher to get the right size at run time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文