答案 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>