locked
Simple question: how can I get a grid to use a scrollbar? RRS feed

  • Question

  • This question may be mind-bogglingly simple: I'm trying to create either a canvas or grid that, if bigger than the actual screen its on, will allow you to scroll down/to the right if you so wish. I tried simply applying a scrollbar control to a grid/canvas that had more on it than could fit on the screen, and it didn't function properly. Any suggestions?
    Thursday, February 2, 2012 11:53 PM

All replies

  • Have you tried wrapping your grid in a scroll viewer?

    The grid and canvas both show properties in Blend for a scroll bar, but they don't work.

    ~Christine


    <ScrollViewer x:Name="myScrollViewer" HorizontalAlignment="Left" Margin="272,316,0,304" Width="100" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto" >
    			<Grid x:Name="myReallyLargeGrid" Height="500" Width="500">
    				<Grid.Background>
    					<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
    						<GradientStop Color="Black" Offset="0"/>
    						<GradientStop Color="White" Offset="1"/>
    					</LinearGradientBrush>
    				</Grid.Background>
    			</Grid>
    		</ScrollViewer>

     

    Setting the scroll bars on the ScrollViewer to "Auto" will have them only show up if your grid is larger than the viewer.

    Friday, February 3, 2012 1:59 AM
  • Christine nailed it, wrap your panel in a scrollviewer.
    Friday, February 3, 2012 5:27 PM
    Moderator