views:

18

answers:

1

Is there any way to modify an html page hosting a Silverlight page using the embedded Silverlight application? I already know how to access existing html elements, but I'm not sure how to add and remove elements dynamically. Thanks in advance.

A: 

Once you got hold of an HtmlElement, use its API to add/remove an element, i.e. use the AppendChild, RemoveChild methods. Or set properties of an element with SetProperty. See MSDN for the full API.

Timores
Okay, how would I do that for a <p></p> tag? How would I get text in between the two tags?
SilverDark
Note that this is more a DOM question than a Silverlight one. Have a look at http://forums.silverlight.net/forums/p/12022/39574.aspx or http://www.switchonthecode.com/tutorials/silverlight-tutorial-interaction-with-the-dom, Changing the text of an element is done by setting the innerHTML property of this element. So, use p.SetProperty("innerHtml", "new value") once you got hold of the <p> element
Timores