I'm attempting to use the code below to make a horizontal listbox in WP7 silverlight. The items appear horizontally but the scrolling is still vertical.
Am I doing something wrong in wpf? Is this a WP7 specific bug?.
<Style TargetType="ListBox" x:Name="HorizontalListBox">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"
IsItemsHost="True"
CanHorizontallyScroll="True"
CanVerticallyScroll="False"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
Edit: I was missing two properties that appear to make a great deal of difference. (The solution came from the second link in the accepted answer by Mick N.)
<Style TargetType="ListBox" x:Name="HorizontalListBox">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal" IsItemsHost="True" CanHorizontallyScroll="True" CanVerticallyScroll="False"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/>
</Style>
Two solutions proposed here you can try out.
Horizontal Listbox?
How to write a control similar to ListBox, but sliding left to right instead of up and down
OK, almost two years later, but Mahantesh's code worked fine for me with only 2 additions, of disabling the VerticalScrollBar property in both the ScrollViewer line and in the ListBox line, to avoid the ListBox still being able to scroll vertically
This is code which is working for me.