【问题标题】:WP7 how to implement a better pivot control?WP7如何实现更好的支点控制?
【发布时间】:2012-11-25 09:55:32
【问题描述】:

我正在使用枢轴控制来显示大量图像(大约 300 张)。我想只使用 3 个枢轴项目,当用户滑动时,更改枢轴项目或更新项目源。但我不知道如何有效地做到这一点?

或者有没有办法像枢轴一样使用手势和刺激滑动效果?过渡之类的?

【问题讨论】:

    标签: windows-phone-7 pivot swipe


    【解决方案1】:

    您可以使用带有手势操作事件的普通图像控制来从左向右和从右向左滑动来查看上一张/下一张照片。

    请在下面找到代码。

    XAML Code 
    
      <!--ContentPanel - place additional content here-->
      <Grid x:Name="ContentPanel" Margin="0">        
         <Image Margin="0" x:Name="ImagePanel"  Source="{Binding SelectedPhoto.PhotoURL}" Stretch="Uniform" HorizontalAlignment="Center" VerticalAlignment="Center"/>
      </Grid>
    
    C# code 
      public SlideShow()
         {
      // Tag ManipulationCompleted event for the current page in the constructor. 
        ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(SlideShow_ManipulationCompleted);
         }
    
        // ManipulationCompleted event. Update the Previous/next photo based on the swipe direction. 
     void SlideShow_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
            {
                var manipEndPoint = e.TotalManipulation.Translation;
                const int threshold = 100;
    
                if ((manipEndPoint.X > _manipStartPoint.X) && ((manipEndPoint.X - _manipStartPoint.X) > threshold))
                {
                    LoadPreviousPhoto();
                }
                else if ((manipEndPoint.X < _manipStartPoint.X) && ((_manipStartPoint.X - manipEndPoint.X) > threshold))
                {
                    LoadNextPhoto();
                }
            }
    

    如果您需要更多帮助,请告诉我。

    谢谢, 卡马尔。

    【讨论】:

    • 感谢您的解决方案。但是你能提供一些方法来获得像枢轴一样的滑动效果吗?有时用户只需按住并水平拖动它。
    猜你喜欢
    • 1970-01-01
    • 2015-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-17
    • 1970-01-01
    相关资源
    最近更新 更多