Windows phone - 避免滚动放置在滚动查看器中的 Web 浏览器控件 [英] Windows phone - Avoid scrolling of Web browser control placed inside scroll viewer

查看:58
本文介绍了Windows phone - 避免滚动放置在滚动查看器中的 Web 浏览器控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须在 Windows Phone 应用程序中在滚动查看器中显示 Web 浏览器,并满足以下要求:

I have to show a web browser inside a scroll viewer in windows phone application, with these requirements :

  1. Web 浏览器的高度根据其内容进行调整.
  2. 网络浏览器滚动应该禁用,(当用户在网络浏览器中滚动时,滚动查看器的滚动应该发生)
  3. Web 浏览器可以缩放并导航到其内容中的链接.

  1. Web browser height should be adjusted based on its content.
  2. Web browser scrolling should be disabled, ( when user scrolls within web browser, scrolling of scroll viewer should take place )
  3. Web browser can do pinch-zoom and navigate to links inside its content.

我该如何实现?非常感谢任何链接或示例.

How can I implement that? Any links or samples is greatly appreciated.

推荐答案

我正在使用这样的代码.将事件附加到浏览器控件树中的 Border 元素(我正在使用 Linq to Visual Tree - http://www.scottlogic.co.uk/blog/colin/2010/03/linq-to-visual-tree/).

I'm using code like this. Attach events to the Border element in the Browser control tree (I'm using Linq to Visual Tree - http://www.scottlogic.co.uk/blog/colin/2010/03/linq-to-visual-tree/).

        Browser.Loaded += 
            (s,e)=>
                {
                    var border = Browser.Descendants<Border>().Last() as Border;

                    if (border != null)
                    {
                        border.ManipulationDelta += BorderManipulationDelta;
                        border.ManipulationCompleted += BorderManipulationCompleted;
                        border.DoubleTap += BorderDoubleTap;
                    }
                };

此外,我正在使用的实现是防止捏合和缩放,这是您想要的工作.虽然这应该可以帮助您朝着正确的方向前进.

Further more the implementation I'm using is to prevent pinch and zoom, something you want to have working. Though this should help you in the right direction.

private void BorderDoubleTap(object sender, GestureEventArgs e)
{
    e.Handled = true;
}

private void BorderManipulationDelta(object sender, ManipulationDeltaEventArgs e)
{
    // suppress zoom
    if (Math.Abs(e.DeltaManipulation.Scale.X) > 0.0||
        Math.Abs(e.DeltaManipulation.Scale.Y) > 0.0)
        e.Handled = true;
}

private void BorderManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
{
    // suppress zoom
    if (Math.Abs(e.FinalVelocities.ExpansionVelocity.X) > 0.0 ||
        Math.Abs(e.FinalVelocities.ExpansionVelocity.Y) > 0.0)
        e.Handled = true;
}

这篇关于Windows phone - 避免滚动放置在滚动查看器中的 Web 浏览器控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆