tags:

views:

520

answers:

1

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?

A: 

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

serge_gubenko
Thank you very much, Serge. That got me on the right way. The scrollviewer isn't on row 2, so I changed the stackpanels on rows 2 and 3 and it worked beautifully! The problem now seems to be the scrollviewer, since it's making row 1 huge now that the others are under control. I tried changing it's size, which didn't do much, then I got rid of the rowspan and things lined up correctly. Except for the scrollviewer itself.I want the scrollviewer selection to span from row1 to the bottom of the screen, but without rowspan it's invisible when row2 starts. Are there any work arounds for this?
Califer
I guess putting scrollviewer's height back to "auto" should get it spanned across rows, I guess smth like this:..ScrollViewer Grid.Row="1" Grid.Column="1" Grid.RowSpan="6" Height="Auto"..
serge_gubenko
it has to work on windows and works fine for me; there are could be problems with parsing pdf files but ususally you get an error message from gs with an explanation of what is missing or broken; can you post up your pdf file somewere on file sharing service so I could try converting it
serge_gubenko
ups... sorry, pls disregard the commect above; wrong thread
serge_gubenko
Oddly enough, removing Height="Auto" and just leaving it blank took care of the problem. Thank you and Happy (Holiday of your choice)!
Califer
thnx, I guess having nested grids might do what you need
serge_gubenko