我希望能够控制Windows Phone 8 WebBrowser控件中的双击缩放,但我无法在WebBrowser控件中捕获双击事件。由于我展示的页面来自于第三方,因此我也不能使用标签属性指定缩放。有没有人遇到过这样的问题?很明显,我已经困扰了两天以上,还没有解决方案。
非常感谢任何帮助!
敬礼, Mawy
非常感谢任何帮助!
敬礼, Mawy
你好,以下是我用于停止滚动、缩放和双击的代码。在我的Windows Phone 8和Windows Phone 8.1(SilverLight)项目中运行良好。
#region stop zoom and scroll
public bool ScrollDisabled { get; set; }
private void WB_Loaded(object sender, RoutedEventArgs e)
{
var border = WB.Descendants<Border>().Last() as Border;
ScrollDisabled = true;
border.ManipulationDelta += Border_ManipulationDelta;
border.ManipulationCompleted += Border_ManipulationCompleted;
border.DoubleTap += border_DoubleTap;
//Debug.WriteLine("Height " + border.Child);
//ContentPresenter cp = border.Child as ContentPresenter;
//Debug.WriteLine("ContentPresenter " + cp.Height);
//cp.Height = 650;
//Debug.WriteLine("ContentPresenter " + cp.Content);
//Grid gd = cp.Content as Grid;
//Debug.WriteLine("ContentPresenter " + gd.Children.First());
//border.MaxHeight = 700;
}
void border_DoubleTap(object sender, System.Windows.Input.GestureEventArgs e)
{
// suppress double-tap zoom
e.Handled = true;
}
private void Border_ManipulationCompleted(object sender,
ManipulationCompletedEventArgs e)
{
if (e.FinalVelocities.ExpansionVelocity.X != 0.0 ||
e.FinalVelocities.ExpansionVelocity.Y != 0.0
||(ScrollDisabled && e.IsInertial))
{
e.Handled = true;
Debug.WriteLine("Scroll ManipulationCompleted");
}
}
private void Border_ManipulationDelta(object sender,
ManipulationDeltaEventArgs e)
{
// suppress zoom
if (e.DeltaManipulation.Scale.X != 0.0 ||
e.DeltaManipulation.Scale.Y != 0.0)
e.Handled = true;
//optionally suppress scrolling
if (ScrollDisabled)
{
if (e.DeltaManipulation.Translation.X != 0.0 ||
e.DeltaManipulation.Translation.Y != 0.0)
e.Handled = true;
}
}
#endregion
这段代码需要一个C#类,我在这里发布了它。