2017-01-20 100 views
0

如何刪除空白空間?如何從WPF窗口中刪除多餘的垂直空白空間

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

enter image description here

+0

只要改變窗口的高度,什麼都大小你想要的。汽車意味着全高。 –

+0

@MuhammadSaqlain這是我的問題!我希望窗口能夠自動調整內部的大小! – Vahid

回答

1

使用SizeToContent = 「高度」

<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> 
+0

謝謝!你救了我! – Vahid