Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Phone 8 Webbrowser control

I want to control double tap zooming in windows phone 8 webbrowser control, but I could able to catch the double tap event in webbrowser control . I could not able to specify the scaling using the meta tag attributes also, since the page I have been displayingcomes from a thrid party I could not edit the HTML page also, Any one has faced issue like this, this is very obvious I could not able to recover from this for more than 2 days , no solutions ,

Any help would be of greatly appreciated !

Regards, Mawy,

like image 592
Mawy Avatar asked Nov 03 '22 03:11

Mawy


1 Answers

Hi this is my code for stop scrolling , zooming and double tap it is working fine in my project with Windows Phone 8 and 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

for this code its require one c# class which I am posting here

like image 87
Maulik Shah Avatar answered Nov 08 '22 04:11

Maulik Shah