Daniel Bişar
Daniel Bişar

Reputation: 2773

ScrollViewer in Grid

I have the following piece of xaml:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="*" />
        <ColumnDefinition Width="Auto" />
    </Grid.ColumnDefinitions>

    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" Grid.Column="0" Grid.Row="1">
        <ContentControl prism:RegionManager.RegionName="{x:Static local:RegionNames.MainMenuRegion}" />
    </ScrollViewer>
</Grid>

If I set VerticalScrollBarVisibility to Visible everything works fine. If I set it to Auto the ScrollBar is never displayed (even when it would be needed).

Any suggestions?

Upvotes: 3

Views: 6584

Answers (1)

Lunivore
Lunivore

Reputation: 17657

Your containing panel is unconstrained - particularly, you've set Grid.Row=1 to have a height of *, which means "use all the available space". So your panel just grows instead of showing the ScrollViewer.

Try setting it to a constrained height, and the ScrollViewer should appear when the MenuItems in your main menu are too many.

Upvotes: 4

Related Questions