Thursday, September 8, 2011

WebBrowser Control for Windows Phone 7

About how to use the WebBrowser control in your Windows Phone 7 application you can take a look at the related topics below.

Display  Web Content from the Network

Here is a short copy form How to: Display Web Content from the Network Using the WebBrowser Control for Windows Phone

  • From in side a .xaml file:
<phone:WebBrowser Source="http://www.bing.com" />


  • From your .xaml.cs

webBrowser1.Source = new Uri("http://www.bing.com", UriKind.Absolute);

webBrowser1.Navigate(new Uri("http://www.bing.com", UriKind.Absolute));

webBrowser1.Loaded += (object sender, RoutedEventArgs e) =>
{
    webBrowser1.Navigate(new Uri("http://www.bing.com", UriKind.Absolute));
};

Display Static Web Content


Here is a short copy from How to: Display Static Web Content Using the WebBrowser Control for Windows Phone


public MainPage()
{    InitializeComponent();
 
    SupportedOrientations = SupportedPageOrientation.Portrait
                          | SupportedPageOrientation.Landscape;
 
    webBrowser1.Loaded += WebBrowser_OnLoaded;
}
 
private void WebBrowser_OnLoaded(object sender, RoutedEventArgs e)
{
    SaveFilesToIsoStore();
    webBrowser1.Navigate(new Uri("readme.htm", UriKind.Relative));
}
// the readme.htm here is your own static content

Display Dynamic Web Content


Here is a short copy from How to: Display Dynamically Generated Web Content Using the WebBrowser Control for Windows Phone


public MainPage()
{
      InitializeComponent();
      SupportedOrientations = SupportedPageOrientation.Portrait
                            | SupportedPageOrientation.Landscape;
 
      webBrowser1.Loaded += WebBrowser_OnLoaded;
}
 
private void WebBrowser_OnLoaded(object sender, RoutedEventArgs e)
{
      webBrowser1.NavigateToString("<html><head><meta name='viewport' content='width=480, user-scalable=yes' /></head><body>HTML Text</body></html>"); 
}

Related Topics:


No comments:

Post a Comment