Windows Phone 上拉刷新、下拉刷新

ScrollViewer scrollViewer = new ScrollViewer();

// 构造函数

public MainPage()

{

    InitializeComponent();

    for (int x = 0; x <= 30; x++)

    {

        listBox1.Items.Add(x);

    }

}



private double actuableOffset, validStartOffset;

private bool mplStarted;

protected override void OnManipulationStarted(ManipulationStartedEventArgs e)

{

     base.OnManipulationStarted(e);

     mplStarted = true;

}



protected override void OnManipulationCompleted(ManipulationCompletedEventArgs e)

{

     //150是下拉的距离可以自己调适

   if (actuableOffset > 150 && scrollViewer.VerticalOffset == 0)

    {

        MessageBox.Show("Head pull bingo!");

    }

    if (actuableOffset < -150 && scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight)

    {

        MessageBox.Show("Tail pull bingo!");

    }

        base.OnManipulationCompleted(e);

}



protected override void OnMouseMove(MouseEventArgs e)

{

    //head capture startRelative

    if (scrollViewer.VerticalOffset == 0)

    {

        if (mplStarted)

        {

            mplStarted = false;

            validStartOffset = e.GetPosition(null).Y;

         }

         actuableOffset = e.GetPosition(null).Y - validStartOffset;

     }

      //tail

      if (scrollViewer.VerticalOffset == scrollViewer.ScrollableHeight)

      {

          if (mplStarted)

          {

              mplStarted = false;

              validStartOffset = e.GetPosition(null).Y;

          }

          actuableOffset = e.GetPosition(null).Y - validStartOffset;

        }

        //UIControlHelper.FindFirst<Pivot>().Title = actuableOffset;

        base.OnMouseMove(e);

}

 

你可能感兴趣的:(windows phone)