繁体   English   中英

WPF 窗口在运行时挤压

[英]WPF window squeezes at runtime

我在 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">

尝试分别为 Height 和 Width 更改 DesignHeight 和 DesignWidth,并将 SizeToContent 设置为 None。

您使用了错误的属性。 DesignWidth 和 DesignHeight 只设置设计时大小。 你想要宽度和高度。

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

暂无
暂无

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

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