如何从WPF窗口中删除额外的垂直空白区域

时间:2017-01-20 09:34:34

标签: c# wpf window

如何删除空格?

break

enter image description here

1 个答案:

答案 0 :(得分:1)

使用SizeToContent =“Height”

<Window x:Class="AnnoCopyDialog.RebarPasteWindow"
        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:AnnoCopyDialog"
        mc:Ignorable="d"
        ResizeMode="NoResize"
        Background="#f0f0f0"
        FontSize="11"
        Title="Paste Window"  Width="420" Height="Auto" SizeToContent="Height">
    <Grid Margin="10">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Margin="0 15 0 0" HorizontalAlignment="Right">

            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
                <Button Content="OK" HorizontalAlignment="Center" Width="70"/>
            </StackPanel>


        </Grid>
    </Grid>
</Window>