在运行时压缩WPF窗口

在运行时压缩WPF窗口

问题描述:

我在Visual Studio 2010中设计了一个WPF窗口,其中包含多个控件。该窗口被设置为程序启动的默认值。此窗口的大小足以让所有控件正确适配。在运行时压缩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"> 
+0

你能告诉我们xaml`Window`开始标签吗? – 2010-12-02 20:01:39

+0

只需将其添加到原始问题。 – SharpAffair 2010-12-02 20:06:06

尝试分别改变DesignHeight和DesignWidth为高度和宽度,并且还SizeToContent设置为无。

您正在使用错误的属性。 DesignWidth和DesignHeight仅设置设计时间的大小。你需要宽度和高度。