【发布时间】:2010-12-29 08:20:56
【问题描述】:
我整天都在为此烦恼。出于某种原因,当我在使用一些自定义控件时设置网格时,网格行的实际高度会发生变化,并且不会费心使用我给它的高度值。我最初认为这是因为我在代码中加载了自定义控件,但即使我将自定义控件取出,问题仍然存在。这是我为 xaml 准备的内容
<Window x:Class="Pokemon_Planner.PokePlan"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="PokePlan" Height="600" Width="800">
<Grid x:Name="myGrid">
<Grid.RowDefinitions>
<RowDefinition Height="25" Name="row0"></RowDefinition>
<RowDefinition Height="Auto" Name="row1"></RowDefinition>
<RowDefinition Height="48" Name="row2"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="1" Grid.Row="0">
<ComboBox Name="cmbSort" Width="100">
<ComboBoxItem Content="Name"></ComboBoxItem>
<ComboBoxItem Content="Type"></ComboBoxItem>
<ComboBoxItem Content="Element"></ComboBoxItem>
<ComboBoxItem Content="BP"></ComboBoxItem>
<ComboBoxItem Content="Min Damage"></ComboBoxItem>
<ComboBoxItem Content="Max Damage"></ComboBoxItem>
</ComboBox>
<Button Name="btnSort" Click="btnSort_Click">Sort</Button>
<Button Name="btnRefresh" Click="btnRefresh_Click">Refresh</Button>
<Button Name="btnFilter">Filter</Button>
</StackPanel>
<StackPanel Grid.Column="0" Grid.Row="2" Orientation="Horizontal" VerticalAlignment="Top" Name="stkMoveSet1">
</StackPanel>
<StackPanel Grid.Column="0" Grid.Row="3" Orientation="Horizontal" Name="stkMoveSet2">
</StackPanel>
<ScrollViewer Grid.Row="1" Grid.Column="1" Grid.RowSpan="6" Height="Auto" Name="scrollViewerMoves" >
<StackPanel Grid.Row="1" Grid.Column="1" Grid.RowSpan="6" Name="moveStackPanel"></StackPanel>
</ScrollViewer>
</Grid>
设置为高度 48 的行仍然设置了该高度,但“实际高度”是 446,这仍然真的把我的网格搞砸了。数字各不相同,我在 set numbers 和 auto 之间尝试了很多不同的组合,但我似乎无法让这个窗口正常运行。有什么想法吗?
【问题讨论】: