locked
Put 2 StackPanels near eachoter like a table with a scrollview

    Question

  • I can get those 2 StackPanels near eachother like a table, but when i add a scrollview to it it puts the Panels under eachother, any ideas?

    Here is my code:

    <Grid x:Name="ContentPanel" Grid.Row="3" Margin="12,0,12,0"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"></ColumnDefinition> <ColumnDefinition Width="*"></ColumnDefinition> </Grid.ColumnDefinitions> <ScrollViewer> <StackPanel> <StackPanel Orientation="Vertical" Grid.Column="0" Margin="12,0,50,0"> <TextBlock Text="Test:"></TextBlock>

    <TextBlock Text="Test:"></TextBlock>

    <TextBlock Text="Test:"></TextBlock>

    </StackPanel> <StackPanel Orientation="Vertical" Grid.Column="1" Margin="12,0,50,0"> <TextBlock Text="Test:"></TextBlock> <TextBlock Text="Test:"></TextBlock> <TextBlock Text="Test:"></TextBlock> </StackPanel> </StackPanel> </ScrollViewer> </Grid>


           



          
     







    Sunday, March 16, 2014 12:45 PM

Answers

  • The stack panels are no longer in the grid so the grid column no longer applies. Maybe use a stack panel with it orientation set to horizontal so they next to each other instead of on top of

    <Grid x:Name="ContentPanel" Grid.Row="3" Margin="12,0,12,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <ScrollViewer>
                    <StackPanel orientation="horizontal">
                        <StackPanel Orientation="Vertical" Grid.Column="0" Margin="12,0,50,0">
                            <TextBlock Text="Test:"></TextBlock>
    
                            <TextBlock Text="Test:"></TextBlock>
    
                            <TextBlock Text="Test:"></TextBlock>
    
                            
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Column="1" Margin="12,0,50,0">
                            <TextBlock Text="Test:"></TextBlock>
                            <TextBlock Text="Test:"></TextBlock>
                            <TextBlock Text="Test:"></TextBlock>
                        </StackPanel>
                    </StackPanel>
                </ScrollViewer>
    </Grid>
    
    

    • Marked as answer by x ApolluMi x Sunday, March 16, 2014 7:29 PM
    Sunday, March 16, 2014 1:53 PM

All replies

  • The stack panels are no longer in the grid so the grid column no longer applies. Maybe use a stack panel with it orientation set to horizontal so they next to each other instead of on top of

    <Grid x:Name="ContentPanel" Grid.Row="3" Margin="12,0,12,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <ScrollViewer>
                    <StackPanel orientation="horizontal">
                        <StackPanel Orientation="Vertical" Grid.Column="0" Margin="12,0,50,0">
                            <TextBlock Text="Test:"></TextBlock>
    
                            <TextBlock Text="Test:"></TextBlock>
    
                            <TextBlock Text="Test:"></TextBlock>
    
                            
                        </StackPanel>
                        <StackPanel Orientation="Vertical" Grid.Column="1" Margin="12,0,50,0">
                            <TextBlock Text="Test:"></TextBlock>
                            <TextBlock Text="Test:"></TextBlock>
                            <TextBlock Text="Test:"></TextBlock>
                        </StackPanel>
                    </StackPanel>
                </ScrollViewer>
    </Grid>
    
    

    • Marked as answer by x ApolluMi x Sunday, March 16, 2014 7:29 PM
    Sunday, March 16, 2014 1:53 PM
  • Yes indeed that did it, i don't need the column definitions then. Thank you.
    Sunday, March 16, 2014 7:29 PM