How do I get a Horizontal ListBox to scroll horizontally in WP7?

前端 未结 3 1610
眼角桃花
眼角桃花 2020-12-30 09:11

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 doin

相关标签:
3条回答
  • 2020-12-30 09:42

    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

    0 讨论(0)
  • 2020-12-30 09:52

    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

    <ScrollViewer HorizontalScrollBarVisibility="Auto" 
                  VerticalScrollBarVisibility="Disabled" 
                  Margin="0,6,-196,0" 
                  Height="Auto" Name="imageScroll">
    <ListBox x:Name="imageBox" 
             ScrollViewer.VerticalScrollBarVisibility="Disabled" 
             Margin="12,0,0,0">
    
    0 讨论(0)
  • 2020-12-30 09:58
     <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" >    
            <ScrollViewer HorizontalScrollBarVisibility="Auto" Margin="0,6,-196,0" Height="Auto" Name="imageScroll">
            <ListBox x:Name="imageBox"  Margin="12,0,0,0">
                    <ListBox.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation ="Horizontal" >
                                <StackPanel.RenderTransform>
                                    <TranslateTransform
                                         X="0" />
                                </StackPanel.RenderTransform>
    
                            </StackPanel>
                        </ItemsPanelTemplate>
                    </ListBox.ItemsPanel>
                        <ListBox.ItemTemplate>
                    <DataTemplate>
                          <Image Source="{Binding Avatar}" Width="240" Stretch="Fill" Height=" 100" />
                        <!--<TextBlock TextWrapping="Wrap" Text="{Binding Titulo}" FontSize="35" VerticalAlignment="Center" Margin="0,10" />-->                       
                    </DataTemplate>
                </ListBox.ItemTemplate>                
            </ListBox>
            </ScrollViewer>
        </Grid>
    

    This is code which is working for me.

    0 讨论(0)
提交回复
热议问题