如何在Windows手机的csharp中停止浏览器导航

时间:2014-09-19 12:53:06

标签: c# windows-phone

我想停止浏览器导航,当我点击按钮时。我尝试了以下方法,但它没有工作。

    private void webBrowser1_Navigating(object sender, NavigatingEventArgs e)
    {
        button2.Click += new RoutedEventHandler((object caller,System.Windows.RoutedEventArgs f) =>
        { 
            e.Cancel = true;
        });
    }

2 个答案:

答案 0 :(得分:0)

试试这个 -

private void webBrowser_Navigating(object sender, NavigatingEventArgs e)
    {
        stop.IsEnabled=true;
        stop.Click += new RoutedEventHandler((object caller, System.Windows.RoutedEventArgs f) =>
        {
            stopPressed = true;
        });

        if (stopPressed == true)
            e.Cancel = true;
    }

答案 1 :(得分:0)

如果您想停止浏览器浏览,可以尝试这样:

       private void stop_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            MiniBrowser.InvokeScript("eval", "document.execCommand('Stop');");
        }