【问题标题】:WPF window squeezes at runtimeWPF 窗口在运行时挤压
【发布时间】:2010-12-02 19:56:47
【问题描述】:

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

【问题讨论】:

  • 你能给我们看看 xaml Window 开始标签吗?
  • 刚刚添加到原始问题中。

标签: .net wpf visual-studio-2010 window designer


【解决方案1】:

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

【讨论】:

  • 我第一次使用 WPF 时经常发生这种情况 :)
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    相关资源
    最近更新 更多