Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertical Scroll in stackpanel

Tags:

wpf

I am trying to get a scroll bar to be placed on a stack panel. The scroll bar displays but will not allow for the user to move the scroll bar at all. Is there something wrong with my XMAL or is there more to it?

<GroupBox HorizontalAlignment="Left" Margin="268,8,0,0" VerticalAlignment="Top" Width="505.881" Height="352.653" Header="Metrics">
<Grid>
    <ScrollViewer>
        <StackPanel>
              </StackPanel>
          </ScrollViewer>
      </Grid>
</GroupBox>

The content of the stack panel is expanders with data contained with in them.

like image 587
joshwl2003 Avatar asked Sep 01 '10 18:09

joshwl2003


1 Answers

You must not set the Width and Height of the GroupBox in order to make the inner ScrollViewer work. Try this out and you'll see that it will work fine.

<GroupBox Header="Metrics" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="268,8,0,0">
    <Grid>
        <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
            <StackPanel>
                <Expander Header="Expander">
                    <StackPanel>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                        <Button>Test</Button>
                    </StackPanel>
                </Expander>

            </StackPanel>
        </ScrollViewer>
    </Grid>
</GroupBox>
like image 75
ASanch Avatar answered Sep 22 '22 09:09

ASanch