制作刷卡工作支点控制与在Windows Phone 8.0的嵌入式web浏览器 [英] Making swipe work for a pivot control with embedded WebBrowser on Windows Phone 8.0

查看:108
本文介绍了制作刷卡工作支点控制与在Windows Phone 8.0的嵌入式web浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的应用程序有每个<$ C $一个 web浏览器控制透视控制C> PivotItem 。问题是,滑动到下一个 PivotItem 不起作用,因为它不是导致水平滚动网页。然而,网页作出响应,并且不需要被水平滚动,以便代替欲导致枢轴开关横向滑动。这能实现呢?如果我不能使用透视控制什么来实现与的WebControl 页面切换的推荐方法S于网页?一位高级菜单一拉的iOS / Android的?

I'd like my application to have a Pivot control with a WebBrowser control in each PivotItem. The problem is that swiping to next PivotItem doesn't work since it instead results in scrolling the web page horizontally. However, the web pages are responsive and doesn't need to be scrolled horizontally so instead I want horizontal swiping to result in a pivot switch. Can this be accomplished? If I can't use a Pivot control what is the recommended way to implement page switching with WebControls on the pages? A top menu a la iOS/Android?

推荐答案

是的,它是可能的,但是需要很少的解决办法,因为的网页浏览器第一次处理事件并您的枢轴可能不知道这件事。你可以使用这个目的触摸及其活动 FrameReported 。简单的代码可以是这样的:

Yes it is possible, however needs little workaround since Webbrowser handles the event first and your Pivot probably doesn't know about it. You can use for this purpose Touch and its event FrameReported. Simple code can look like this:

public MainPage()
{
   InitializeComponent();
   Touch.FrameReported += Touch_FrameReported;
}

TouchPoint first;

private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
   TouchPoint mainTouch = e.GetPrimaryTouchPoint(myWebBrowser);
   if (mainTouch.Action == TouchAction.Down)
         first = mainTouch;
   else if (mainTouch.Action == TouchAction.Up)
   {
       if (mainTouch.Position.X - first.Position.X < 0)
            MessageBox.Show("Next item.");
           //myPivot.SelectedIndex++;
       if (mainTouch.Position.X - first.Position.X > 0)
           MessageBox.Show("Previous item.");
          //myPivot.SelectedIndex--;
   }
}



正如你所看到 - 我想起了在那里用户开始他的动作,那么当他释放他的触摸 - 我改变myPivot.SelectetIndex。希望这有助于一点。您也可以尝试用的TouchPanel ,但我认为这会更简单(如果它是足够了)。

As you can see - I'm remembering the where the user start his movements, then when he releases his touch - I change myPivot.SelectetIndex. Hope this helps a little. You can also try with TouchPanel, but I think that will be simpler (if it's sufficient).

如果您要禁用一些手势就可以寻找类似的例子在下面的代码。我只启用了Horizo​​ntalDrag - 所以它不会火变焦。当然公差不应该是0,你必须定义出最适合你的应用程序。

If you want to disable some gestures it can look for example like in the code below. I enabled only HorizontalDrag - so it won't fire for zoom. The tolerance of course shouldn't be 0, you will have to define the most suitable for your App.

// in MainPage() constructor
TouchPanel.EnabledGestures = GestureType.HorizontalDrag; 

private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
   TouchPoint mainTouch = e.GetPrimaryTouchPoint(myMap);
   if (mainTouch.Action == TouchAction.Down)
        first = mainTouch;
   else if (mainTouch.Action == TouchAction.Up && TouchPanel.IsGestureAvailable)
   {
      if (mainTouch.Position.X - first.Position.X < 0)
        MessageBox.Show("Next item.");
        //myPivot.SelectedIndex++;
      if (mainTouch.Position.X - first.Position.X > 0)
        MessageBox.Show("Previous item.");
        //myPivot.SelectedIndex--;
   }
}

这篇关于制作刷卡工作支点控制与在Windows Phone 8.0的嵌入式web浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆