Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 检测用户何时执行垂直滚动_C#_.net_Windows Phone 7_Scroll - Fatal编程技术网

C# 检测用户何时执行垂直滚动

C# 检测用户何时执行垂直滚动,c#,.net,windows-phone-7,scroll,C#,.net,Windows Phone 7,Scroll,我在我的一个windows phone应用程序屏幕中使用了一个Pivot,我想检测用户是否正在执行垂直滚动。 我注意到没有用于检测它的内置事件,而且我还注意到ScrollViewer、Grid等没有Scroll属性。 我想知道是否有可能检测到垂直滚动。如果有人能给我指出解决办法,我将不胜感激。提前谢谢 <ScrollViewer Name="mailSV"> <controls:Pivot Name="mailPivot" Title="EyeLight">

我在我的一个windows phone应用程序屏幕中使用了一个
Pivot
,我想检测用户是否正在执行垂直滚动。 我注意到没有用于检测它的内置事件,而且我还注意到
ScrollViewer、Grid等
没有Scroll属性。 我想知道是否有可能检测到垂直滚动。如果有人能给我指出解决办法,我将不胜感激。提前谢谢

<ScrollViewer Name="mailSV">
    <controls:Pivot Name="mailPivot" Title="EyeLight">
        <!--Pivot item one-->
        <controls:PivotItem Name="GmailPivot" Header="Gmail">
            <!--Double line list with text wrapping-->
            <Button Name="Gmail" Tap="mailSingleTap" DoubleTap="listenMode" FontSize="120" Foreground="Black">
                <Button.Background>
                    <ImageBrush ImageSource="/ScrollingApp;component/Images/Gmail-icon.png" Stretch="Uniform" />
                </Button.Background>
            </Button>
        </controls:PivotItem>

            <!--Pivot item two-->
        <controls:PivotItem Name="YahooPivot" Header="Yahoo">
            <!--Triple line list no text wrapping-->
            <Button Name="Yahoo" FontSize="120" Tap="mailSingleTap" DoubleTap="listenMode" Foreground="Black">
                <Button.Background>
                    <ImageBrush ImageSource="/ScrollingApp;component/Images/yahoo2.jpeg" Stretch="Uniform" />
                </Button.Background>
            </Button>
        </controls:PivotItem>
    </controls:Pivot>
</ScrollViewer>

试试这个,它在列表框的情况下对我有效

定义以下方法和属性

ScrollViewer scrollViewer;

 private static void OnListVerticalOffsetChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
            {
                //Create an object of the same class(page).      
                MyPage page = obj as MyPage ;

                ScrollViewer viewer = page.scrollViewer;

                //Checks if the Scroll has reached the last item based on the ScrollableHeight
                bool atBottom = viewer.VerticalOffset >= viewer.ScrollableHeight;

                if (atBottom)
                {
                    //Type your Code here after checking the vertical scroll.               
                }
            }
现在,使用以下代码通过使用上述方法获取ListVerticalOffset的值

public readonly DependencyProperty ListVerticalOffsetProperty = DependencyProperty.Register("ListVerticalOffset", typeof(double), typeof(ImageSearch),
                new PropertyMetadata(new PropertyChangedCallback(OnListVerticalOffsetChanged)));
现在将此属性绑定到ListBox加载事件上的当前实例

void listBox_Loaded(object sender, RoutedEventArgs e)
        {

            FrameworkElement element = (FrameworkElement)sender;
            element.Loaded -= LstImage_Loaded;
            scrollViewer = FindChildOfType<ScrollViewer>(element);
            if (scrollViewer == null)
            {
                throw new InvalidOperationException("ScrollViewer not found.");
            }

            Binding binding = new Binding();
            binding.Source = scrollViewer;
            binding.Path = new PropertyPath("VerticalOffset");
            binding.Mode = BindingMode.OneWay;
            this.SetBinding(ListVerticalOffsetProperty, binding);
        }
void listBox\u已加载(对象发送方,路由目标)
{
FrameworkElement=(FrameworkElement)发送方;
element.Loaded-=LstImage_Loaded;
scrollViewer=FindChildOfType(元素);
如果(scrollViewer==null)
{
抛出新的InvalidOperationException(“未找到ScrollViewer”);
}
绑定=新绑定();
binding.Source=scrollViewer;
binding.Path=新属性路径(“垂直偏移”);
binding.Mode=BindingMode.OneWay;
此.SetBinding(ListVerticalOffsetProperty,binding);
}