2013-03-01 132 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