Reputation: 1269
I have created a wysiwyg editor as a standard C# program using the windows form control. I would like to do the same thing except with WPF.
In my old application I did something like this.
using mshtml;
private IHTMLDocument2 doc;
...
HTMLeditor.DocumentText =
"<html><body></body></html>";
doc = HTMLeditor.Document.DomDocument as IHTMLDocument2;
doc.designMode = "On";
Which allowed the the use of Document.ExecCommand on the editor.
How is this accomplished in WPF? It doesn't look like the WebBrowser control in WPF allows for designmode.
Thanks!
Upvotes: 2
Views: 5639
Reputation: 5813
Try this:
public MyControl()
{
InitializeComponent();
editor.Navigated += new NavigatedEventHandler(editor_Navigated);
editor.NavigateToString("<html><body></body></html>");
}
void editor_Navigated(object sender, NavigationEventArgs e)
{
var doc = editor.Document as IHTMLDocument2;
if (doc != null)
doc.designMode = "On";
}
Edit: where editor is a WebBrowser control.
Upvotes: 6