Silverlight browser interaction: Use the Silverlight program to nest external HTML pages (with source code)

Source: Internet
Author: User

Overview

Webbrowser.NavigateMethod

Load the HTML content in the specified Uri.

The specified URI can be fully limited or become a relative Uri. When you set relative Uri, use the following conventions:

    • "/Page1.html"Is an applicationProgramLevel resource, which is parsed as the base URI of the application (xap file.

Effect

 

XAMLCode

 

  <  Grid  X: Name  = "Layoutroot"  >  
< Grid. Background >
< Lineargradientbrush Startpoint = "0, 0" Endpoint = "0, 1" >
< Gradientstop Color = "# Ff0055dd" Offset = "0" />
< Gradientstop Color = "# Ff00ddff" Offset = "1" />
</ Lineargradientbrush >
</ Grid. Background >

< Webbrowser X: Name = "Web"
Margin = "15" />
</ Grid >

CS code:

   Public  Mainpage ()
{
Initializecomponent ();

Loaded + = New Routedeventhandler (mainpage_loaded );
}

Void Mainpage_loaded ( Object Sender, routedeventargs E)
{
// Webbrowser. navigate Method
// Load the HTML content in the specified Uri.
// The specified URI can be fully limited or become a relative Uri. When you set relative Uri, use the following conventions:
// "/Page1.html" is an application-level resource that is parsed as the base URI of the application (xap file.
Web. navigate ( New Uri ( " Example-page.html " ,
Urikind. Relative )); // Relative URI
}

HTML page:

 <  Html  Xmlns = "Http://www.w3.org/1999/xhtml"  >  
< Head ID = "Head1" Runat = "Server" >
< Title > Demo page </ Title >
</ Head >
< Body >
< Div Style = "Margin: 20px; font-family: Arial; font-size: 16pt" >
This is an out-of-browser application:
< P >
The Silverlight program is nested with HTML pages from the same domain. < A Href = "Example-page.html" > Silverlight </ A >
The HTML page in the program does not exist.
</ Div >
< Div Style = "Margin: 20px" >
< IMG SRC = "Ying.gif" />
</ Div >
</ Body >
</ Html >

Success !!!

Source code download

Author:Memories of lost youth
Source: http://www.cnblogs.com/lukun/
The copyright of this article is shared by the author and the blog. You are welcome to repost this article, but you must keep this statement without the author's consent andArticleThe original text connection is displayed at an obvious location on the page. If you have any problems, you can useHttp://www.cnblogs.com/lukun/Thank you very much for contacting me.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.