Learning Silverlight 2 Series (20): How to interact with the HTML DOM in Silverlight (bottom)

Source: Internet
Author: User
Tags html page silverlight

The support for HTML, client script, and so on is built into Silverlight, and this article is the second part of how to interact with the HTML DOM in Silverlight 2. In the first section, we mainly introduce how to access and modify the existing HTML DOM, we can also completely create a new DOM element or remove an existing DOM element, in addition, we can add event handling for DOM elements.

Creating DOM elements

First, let's look at how to create a new DOM element, the final effect is as follows, when we enter text in a text box, click Create and create an LI element in the area above.

First define the HTML page, even the height of the Silverlight plug-in.

<div id="parentdiv">
  <ul id="list">
   </ul>
</div>
<div  style="height:200px;">
  <asp:Silverlight ID="Xaml1" runat="server"
   Source="~/ClientBin/TerryLee.SilverlightAccessDom2.xap"
   Version="2.0" Width="100%" Height="200px" />
</div>

and define a simple style for the div above to differentiate it from Silverlight

#parentdiv
{
  background:#FCDFB3;
   border:solid 1px #FF9900;
  width:500px;
  height:100px;
  margin-bottom:20px;
}

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.