Thursday, July 07, 2011

Creating a horizontally scrolling list #wp7dev

I recently needed to show someone how to make a ListBox scroll horizontally rather than vertically. Here's what I did:

  
      
          
              
              
          
      
      
          
              
              
          
      
  

The key part is: '<StackPanel Orientation="Horizontal" />'
It's this that controls the direction. of item display.

The next two parts give us the correct scrolling behaviour that we want.
Setting 'ScrollViewer.HorizontalScrollBarVisibility="Auto"' enables horizontal scrolling.
Setting 'ScrollViewer.VerticalScrollBarVisibility="Disabled"' prevents vertical scrolling.

The thing to note is that setting XxxxScrollBarVisibility doesn't just control the visibility if the scrollbar it also controls whether scrolling in that direction is possible.

0 comments:

Post a Comment

I get a lot of comment spam :( - moderation may take a while.