Silverlight: Scrolling with a StackPanel
Posted
by programatique
on Stack Overflow
See other posts from Stack Overflow
or by programatique
Published on 2010-04-22T13:34:15Z
Indexed on
2010/04/22
19:53 UTC
Read the original article
Hit count: 1112
I have a grid, 3 by 3 (3 rowdefinitions and 3 columndefinitions). I want some content (a StackPanel) in one of those grid cells to scroll. I'm fairly sure this is possible but I cannot figure out how. I've tried adding ScrollViewers and Scrollbar controls to the grid cell I want to scroll, but this usually ends up creating scrolling for the entire page.
Edit: My issue is more specificlly how I can get scrolling over a StackPanel. An example if the issue I am having is here:
<Grid x:Name="LayoutRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid>
<TextBlock FontSize="16">1,1</TextBlock>
</Grid>
<Grid Grid.Column="1">
<TextBlock FontSize="16">1,2</TextBlock>
</Grid>
<Grid Grid.Row="1">
<TextBlock FontSize="16">2,1</TextBlock>
</Grid>
<Grid Grid.Column="1" Grid.Row="1">
<StackPanel>
<TextBlock>Title</TextBlock>
<Grid>
<ScrollViewer>
<StackPanel>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
<TextBlock FontSize="32">2,2</TextBlock>
</StackPanel>
</ScrollViewer>
</Grid>
</StackPanel>
</Grid>
</Grid>
© Stack Overflow or respective owner