如何在wp7中为scrollviewer / listbox滚动上/下或左/右事件

时间:2011-07-13 12:27:37

标签: windows-phone-7 listbox scroll scrollview

如何为scrollViewer / Listbox滚动上/下或左/右事件?我跟随XAML。我想在用户滚动时收到通知。

<ScrollViewer HorizontalScrollBarVisibility="Auto" Margin="0,6,-196,0" Height="Auto" Name="imageScroll">
    <ListBox x:Name="myListBox"  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>
                <StackPanel Orientation="Horizontal">
                    <TextBlock  Foreground="GreenYellow" FontSize="60" Text="{Binding name}"/>
                    <HyperlinkButton Content="EVTEN" NavigateUri="{Binding price}" Foreground="AliceBlue" FontSize="40" TextOptions.TextHintingMode="Animated"/> 
                    <TextBlock Foreground="Red" Padding="30" FontSize="60" Text="{Binding price}"/>
                    <TextBlock Foreground="GreenYellow"  FontSize="60" Text="{Binding description}"/>
                    <TextBlock Foreground="Red" Padding="30" FontSize="60" Text="{Binding calories}"/>
                </StackPanel>
            </DataTemplate>
        </ListBox.ItemTemplate>
    </ListBox>
</ScrollViewer>

2 个答案:

答案 0 :(得分:0)

Peter Torr有一个excelent blog post,它展示了如何制作一个LazyListBox。该代码显示了如何通过检测ScrollViewer底层框的VisualStateGroup中的更改来检测列表框是否正在滚动。

答案 1 :(得分:0)

在列表框中,您可以向下/向上滚动。

我的代码,希望帮助你向左和向右滚动

<ListBox x:Name="myListBox"  Margin="12,0,0,0">
    <ListBox.ItemsPanel>
        <ItemsPanelTemplate>
            <StackPanel Orientation ="Horizontal" >

            </StackPanel>

            <!-- You can add item contain here -->
        </ItemsPanelTemplate>
    </ListBox.ItemsPanel>

项目似乎包含错误的地方