Assuming you have already followed the instructions to How to use Monaco editor in a WPF application, then you can use javascript editor.GetValue
and editor.setValue
functions to work with the editor.
For example, to get the value of the editor:
var value = await webView21.ExecuteScriptAsync("editor.getValue();");
MessageBox.Show(value);
Or to set the value of the editor:
await webView21.ExecuteScriptAsync("editor.setValue('Hi!');");
Note:
- Use Monaco editor documentations to learn more about supported API.
- Use Monaco editor playground and learn how to use javascript api of the editor.
- Then use WebView.ExecuteScreipAsync to run the scripts.