Question
J'ai créé un éditeur wysiwyg en tant que programme C # standard à l'aide du contrôle de formulaire Windows. J'aimerais faire la même chose sauf avec WPF.
Dans mon ancienne application, j'avais fait quelque chose comme ça.
using mshtml;
private IHTMLDocument2 doc;
...
HTMLeditor.DocumentText =
"<html><body></body></html>";
doc = HTMLeditor.Document.DomDocument as IHTMLDocument2;
doc.designMode = "On";
Qui permettait l'utilisation de Document.ExecCommand sous l'éditeur.
Comment cela est-il accompli dans WPF? Il ne semble pas que le contrôle WebBrowser dans WPF permette le designmode.
Merci!
La solution
Essayez ceci:
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";
}
Modifier: où l'éditeur est un contrôle WebBrowser.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow