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.