The support for HTML, client script, and so on is built into Silverlight, and this article accesses and modifies the DOM elements in the first part of interacting with the HTML DOM in Silverlight 2.
accessing DOM elements
Let's take a look at a simple example of how to access the HTML DOM. The final results are as follows, we will place two div in the interface, respectively, for Div1 and Div2, the green area below is the Silverlight section, enter the div ID in the first text box and click on the display, will display the corresponding div text information below.
First we need to make changes to the test page, because the default Silverlight plug-in's height is 100%, modified to 200px.
<div style="height:200px">
<asp:Silverlight ID="Xaml1" runat="server"
Source="~/ClientBin/TerryLee.SilverlightAccessingHtmlDom1.xap"
Version="2.0" Width="100%" Height="200px" />
</div>
Place two div at the same time:
<div id="div1">这里是第一个div,id为 div1</div>
<div id="div2">这里是第二个div,id为 div2</div>