5

我想在 windows phone 8 webbrowser 控件中控制双击放大,但我可以在 webbrowser 控件中捕获双击事件。我也无法使用元标记属性指定缩放,因为我一直在显示的页面来自第三方我也无法编辑 HTML 页面,任何人都遇到过这样的问题,这很明显我不能能够从中恢复超过2天,没有解决方案,

任何帮助将不胜感激!

问候,莫伊,

4

1 回答 1

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# 类

于 2014-11-28T03:47:48.180 回答