首页 > 解决方案 > 如果已经设置了高度,可以设置设计高度

问题描述

c# 如果设置了高度,可以设置设计高度

<Controls:MetroWindow x:Class="SQL_Reports.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:local="clr-namespace:SQL_Reports"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    mc:Ignorable="d"
    Width="669"
    Title="Daily SQL Reports" 
    WindowStartupLocation="CenterScreen" 
    ScrollViewer.VerticalScrollBarVisibility="Auto" 
    ScrollViewer.CanContentScroll="True" 
    MinHeight="530" 
    TitleAlignment="Center" 
    MinWidth="677" 
    d:DesignHeight="927" >

我正在尝试设置设计高度,以便可以在 Visual Studio 中查看我的内容,但我也希望 WPF 的高度为 530,但是当我设置高度时,设计器保持为 530,而不是我设置的设计高度.

标签: c#wpfxaml

解决方案


只需在设计时去掉 MinHeight="530" 即可。完成后再次添加。

我不相信您可以同时定义运行时高度和设计高度。也许您可以尝试 d:LayoutOverrides 属性。


推荐阅读