我添加了一个WebBrowser作为其中一个全景项目的内容。WebBrowser的渲染没有任何问题。如果我通过触摸WebBrowser外部的区域来滑动全景图,就会发生滑动。但是,当我试图通过触摸WebBrowser来滑动全景图时,并没有发生滑动,而是WebBrowser垂直滚动。你知道怎么解决这个问题吗?
发布于 2013-05-07 19:51:18
我没有投反对票,但可能是因为这不是个好主意。按照设计,这些项目不应该组合在一起。但是,如果您确实希望将浏览器保留在pivot内部,您可以浏览一下here
发布于 2013-10-18 03:53:20
虽然你肯定会发现这不是UI指南推荐的,但在我的情况下这是一个必要的要求,我能够通过直接订阅Touch事件并手动检测滑动来解决这个问题:
// controls "swipe" behavior
private Point touchDownPosition; // last position of touch down
private int touchDownTime; // last time of touch down
private int touchUpTime; // last time of touch up
private int swipeMaxTime = 1000; // time (in milliseconds) that a swipe must occur in
private int swipeMinDistance = 25;// distance (in pixels) that a swipe must cover
private int swipeMinBounceTime = 500; // time (in milliseconds) between multiple touch events (minimizes "bounce")
// handler for touch events
void Touch_FrameReported(object sender, TouchFrameEventArgs e)
{
var item = MyPivot.SelectedItem as PivotItem;
// ignore touch if we are not on the browser pivot item
if (item != BrowserPivotItem)
return;
var point = e.GetPrimaryTouchPoint(item);
switch (point.Action)
{
case TouchAction.Down:
touchDownTime = e.Timestamp;
touchDownPosition = point.Position;
touchUpTime = 0;
break;
case TouchAction.Up:
// often multiple touch up events are fired, ignore re-fired events
if (touchUpTime != 0 && touchUpTime - e.Timestamp < swipeMinBounceTime)
return;
touchUpTime = e.Timestamp;
var xDelta = point.Position.X - touchDownPosition.X;
var yDelta = point.Position.Y - touchDownPosition.Y;
// ensure touch event meets the requirements for a "swipe"
if (touchUpTime - touchDownTime < swipeMaxTime && Math.Abs(xDelta) > swipeMinDistance && Math.Abs(xDelta) > Math.Abs(yDelta))
{
// advance to next pivot item depending on swipe direction
var iNext = MyPivot.SelectedIndex + (delta > 0 ? -1 : 1);
iNext = iNext < 0 || iNext == MyPivot.Items.Count ? 0 : iNext;
MyPivot.SelectedIndex = iNext;
}
break;
}
}然后在需要时订阅Touch.FrameReported,或者为了进行更好的优化,请仅在选择包含浏览器的透视表项时订阅事件处理程序:
private void MyPivot_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
if ((sender as Pivot).SelectedItem == BrowserPivotItem)
Touch.FrameReported += Touch_FrameReported;
else
Touch.FrameReported -= Touch_FrameReported;
}https://stackoverflow.com/questions/16416478
复制相似问题