开发者

WPF grid row height doesn't match the height that I input

I've been pulling my hair out all day on this. For some reason when I set up my grid while I'm using some custom controls the actual height of the grid rows changes around and doesn't bother to use the height values that I give it. I originally thought it was because I was loading in custom controls in the code, but even when I take the custom controls out the problem remains. Here's what I have for the 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>

The row that was set to have a height of 48 still had that height set, but the 'actual height' was 446 which is still really screwing my grid up. The numbers vary and I've tried a lot of different combinations between set numbers and auto but I can't seem to get this one window to behave correctly. Any ideas?


you might want to change "row2" grid row height definition to "auto" and set height to 48 for the "scrollViewerMoves" scrollviewer. Smth like this:

...
<RowDefinition Height="Auto" x:Name="row2"></RowDefinition>
...
<ScrollViewer Grid.Row="1" Grid.Column="1" Height = "48" Name="scrollViewerMoves" >
...

I guess this should do what you need, regards

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜