2013-03-01 130 views
5

我想控制Windows Phone 8 webbrowser控件的双击缩放,但我可以在web浏览器控件中捕获双击事件。我也无法使用元标记属性指定缩放比例,因为我从第三方显示的页面也无法编辑HTML页面,任何人都遇到过这样的问题,这是非常明显的,我不能能够从此恢复超过2天,没有解决方案,Windows Phone 8 Web浏览器控件

任何帮助将不胜感激!

问候, Mawy,

+0

你能更具体吗? DoubleTap事件后,您究竟想达到什么目标?在webbrowser控件上触发双击事件,通常会缩小并默认将内容适合可见区域。 – halil 2014-05-13 10:34:11

回答

2

你好,这是我停止滚动码,缩放和双击它工作正常在我的项目随着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#类here