Embed and use the HTML Rich Text Editor in Silverlight

Source: Internet
Author: User
Tags silverlight

 

First, I would like to complain that Silverlight 4 cannot use Chinese Input in windowless mode. Therefore, there are defects in the method described below.

 

1. Embed HTML pages

 

The tool is a free htmlhost plug-in that can be used to embed HTML pages and URLs in Silverlight.

Http://www.divelements.com/silverlight/tools.aspx

The htmleditor.htm page contains a JS ckeditor and some JS functions that read the editor.

Note that Silverlight must be setWindowlessMode. The principle should be to add an HTML frame element directly on the webpage and then

Overwrite Silverlight.

 

<Grid margin = ","> <br/> <divtools: htmlhost name = "htmlhost" sourceuri = "http: // localhost: 5349/htmleditor/htmleditor.htm "horizontalalignment =" Left "verticalignment =" TOP "width =" 850 "Height =" 400 "documentready =" htmlhost_documentready_1 "> </divtools: htmlhost> <br/> </GRID> 

 

Ii. Call js code embedded on the page

 

The problem now is how to call the JS Code embedded in a page. Because it does not belong to the same page of Silverlight, it cannot directly use Silverlight

Technology to call. I did not solve the problem after I checked a lot of information on the Internet, and in fact I was just switching to a website. html and JS are really cloudification for me.

Fortunately, the project manager with Wei Feng helped me solve this problem.

 

The solution is to write a proxy function on the Silverlight page, and then you can call this proxy function in Silverlight to read or operate.

The editor is embedded in the page.

Function geteditorframe () {<br/> return response parent.doc ument. getelementsbytagname ("iframe") [1]; <br/>}< br/> function getallimgsrc () {<br/> var frame = geteditorframe (); <br/> If (frame = NULL) <br/> return NULL; <br/> return frame. contentWindow. getallimgsrc (); <br/>} 

 

Explanation

Geteditorframe function, which returns the embedded html iframe window.

Use the following methods to call the JS Code of an IFRAME window: compatible with IE and Firefox

Response response parent.doc ument. getelementsbytagname ("iframe") [x]. contentWindow. getallimgsrc ();

X: Can be 0, 1, 2, 3 ..

The frame. contentWindow. getallimgsrc function is the JS function in htmleditor.htm.

 

 

Iii. Summary

 

Silverlight 4 currently has few useful htmleditor controls, and the above method causes all plug-in

Cannot input Chinese characters. It is a tragedy for the full-site Silverlight application.

In the end, we discard this method to directly bring up another page that is not pure Silverlight for editing, and then interact with the home page through the SL message mechanism.

 

Another method should be to separate the editor into a Silverlight plug-in, and then stack the plug-in the SL page, but it seems that there is still scrolling control in the layout.

What is difficult to control? Who can give me a thought?

If you cannot enter Chinese characters, this sl4 is not very powerful. I hope sl5 will be used by the supervisor.

 

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.