Does anyone know of a working example for putting the WPF syntax editor in a winform? I've searched all over, and even chatGPT, but it can't provide a working example.
Hello Sean,
Thank you for contacting Infragistics. This is documented on MSDN
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/walkthrough-hosting-a-wpf-composite-control-in-windows-forms?view=netframeworkdesktop-4.8
After you've added the assemblies for the XamSyntaxEditor, adding the component to a Windows Forms project is fairly straightforward.
eg,
public partial class Form1 : Form { private ElementHost _ctrlHost; public XamSyntaxEditor syntaxEditor; public TextDocument document; public Form1() { InitializeComponent(); _ctrlHost = new ElementHost(); syntaxEditor = new XamSyntaxEditor(); _ctrlHost.Child = this.syntaxEditor; document = new Infragistics.Documents.TextDocument(); document.InitializeText("Hello, World!"); syntaxEditor.Document = document; _ctrlHost.Width = 800; _ctrlHost.Height = 450; this.Controls.Add(_ctrlHost); }
Let me know if you have any questions.
Thanks, that did the trick. One more thing... I'm trying to use it as a sql parser and I'm using the code on this page...
Supported Languages - Infragistics WPF Help
syntaxEditor.Document.Language = TSqlLanguage.Instance;
But it tells me...
Cannot resolve symbol 'TSqlLanguage'
I'd also like to show line numbers.
Dude, it totally works now. Thanks for taking the extra time on this one.
The new app runs fine without errors. Just make sure to include all the assemblies. I noticed you've been mixing WPF4 and the versionfree assemblies.
For context here is what I did, I added the WPF4 syntaxeditor dll and removed the version free ones and everything ran without errors.
Ok, I just uploaded a new version. If you run ConnParameterQB you should get the error at hand and not all the others.
I get the following warning in Visual Studio, and when I rebuild the solution I get two errors
Because the app won't recompile I get the following error prompt on run.
Done.