简体   繁体   中英

use web browser control in feed rss reader

I followed this guide to create a rss reader

http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh487167(v=vs.92).aspx

but I would like to use web browser control to open the feed instead of the WebBrowserTask. How can I achieve it?

Note: I am using C#

With reference to your link. You may follow the following approach:

Create a webBrowser control on your page. Call it say "webBrowser"

Use webBrowser.Navigate(uri); instead of the below three statements

        WebBrowserTask webBrowserTask = new WebBrowserTask();
        webBrowserTask.Uri = uri;
        webBrowserTask.Show();

in the function feedListBox_SelectionChanged . Hope it helps.

call the webBrowser.xaml page like this

NavigationSerivce.Navigate(new Uri("<webBrowser.xaml path>?url="+url,UriKind.Relative));

on the webBrowser.xaml

        <Grid x:Name="ContentPanel" Grid.Row="1" >
             <phone:WebBrowser IsScriptEnabled="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="browser" />
        </Grid>

and on the webBrowser.xaml.cs do:

    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
        String url = NavigationContext.QueryString["url"];
        if (!String.IsNullOrEmpty(url))
        {
            browser.Navigate(new Uri(url));
        }
    }

please Check for compilation errors. It should work

To prevent auto refreshing try this in your webBrowser.xaml.cs

    String _oldUrl;
    protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
    {
         String url = NavigationContext.QueryString["url"];
         if(url!=_oldUrl)
         {
              if (!String.IsNullOrEmpty(url))
              {
                     browser.Navigate(new Uri(url));
              }
              _oldUrl = url;
         }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM