TE Edit Control .NET Core / .NET Framework Help
Product page

WPF Support

Tern control can be hosted within a WPF application using WindowsFormHost control. Here is an example:

XAML:
<Window x:Class="TernWpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="TE Edit Control Demo" Height="599" Width="911" Loaded="Window_Loaded">
    <Grid Name="TernGrid">
    </Grid>
</Window>
Code Behind:
using System.Windows.Forms.Integration;
using SubSystems.TE;
namespace TernWpf
{
  /// <summary>
  /// Interaction logic for MainWindow.xaml
  /// </summary>
  public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
    }
    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
      // Create the interop host control.
      WindowsFormsHost host = new WindowsFormsHost();
      // Create the Tern control.
      Tern tern = new Tern();
      tern.WordWrap = true;
      tern.PageMode = true;
      tern.ShowToolBar = true;
      tern.ShowRuler = true;
      tern.ShowVertRuler = true;
      tern.VertScrollBar = true;
      tern.HorzScrollBar = true;
      tern.ShowStatusBar = true;
      // catch the 'ControlCreated' event to do further initialization 
      tern.ControlCreated += new Tern.EventControlCreated(TernControlCreated);  
      // Assign the MaskedTextBox control as the host control's child.
      host.Child = tern;
      // Add the interop host control to the Grid 
      // control's collection of child controls. 
      this.TernGrid.Children.Add(host);
    }
    /********************************************************************************
     * This event allows you do additional initialization that can be done only
     * after the Tern control is fully created
     * *****************************************************************************/
    private void TernControlCreated(Object sender)
    {
      Tern tern = (Tern)sender;
      tern.TerSetFlags9(true, tc.TFLAG9_ENABLE_POPUP_MENU);  // enable pop-up menu
      tern.Command = tc.ID_SHOW_PAGE_LAYOUT;  // show page layout mode
      tern.Data = @"{\rtf1 \i Please type here \i0\par}";   // assign any initial data
    }
  }
}
For a working example, please refer to the wpf.zip file in the distribution folder.