Tuesday, August 28, 2012

use web browser control in feed rss reader

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#

Answers & Comments...

Answer: 1

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.

by : Milan Aggarwalhttp://stackoverflow.com/users/1378956

Answer: 2

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

by : Milan Aggarwalhttp://stackoverflow.com/users/1378956

Answer: 3

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;          }     } 
by : Milan Aggarwalhttp://stackoverflow.com/users/1378956




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog