Getting Started with WPF (.NET 5 and better)
This article shows how to use the TX Text Control WPF.TextControl class within a .NET 6 application in Visual Studio 2022.

The following tutorial shows how to create a .NET Framework WPF Application that uses the WPF.
Creating the Project
-
Open Visual Studio 2022 and create a new project. Select C# or Visual Basic from the Languages drop-down list, Windows from the Platform list and Desktop as the Project Type. Find the project template WPF Application and confirm with Next.
-
Specify a project name confirm with Next.
-
Select your preferred Framework version such as .NET 6 (Long-term support) and confirm with Create.
Adding the Control
-
Select the project in the Solution Explorer and click Project -> Manage NuGet Packages... from the main menu.
-
Select Text Control Offline Packages as the Package source and click Browse.
-
Select TXTextControl.TextControl.WPF.SDK and click Install.
-
In the XAML view, replace the Grid with a DockPanel control as shown in the below screenshot:
Connecting the Controls
In the next steps, the order in which the controls are added to the Window is important.
-
Find the TX Text Control 31.0 tab in the Toolbox.
-
Double-click the ButtonBar in the Toolbox to add it to the Window.
Getting an error?
For the first element, you will receive a warning similar to the screenshot below. To solve this, select the project in the Solution Explorer and click Rebuild Solution.
Make sure that the Window is selected and not the inserted ButtonBar before adding the following elements.
-
Repeat this for the RulerBar, StatusBar, a second RulerBar and finally TextControl.
-
In the XAML, remove the Height and the Width properties for all added elements.
-
Name all elements according to the following screenshot: buttonBar1, rulerBar1, statusBar, rulerBar2 and textControl1.
-
In the XAML, add the Loaded="textControl1_Loaded" event handler to the TextControl element as a parameter, so that the line looks like this:
<WPF:TextControl Name="textControl1" Loaded="textControl1_Loaded" ButtonBar="buttonBar1" StatusBar="statusBar1" RulerBar="rulerBar1" VerticalRulerBar="rulerBar2"/>
Right-click on textControl1_Loaded and choose Go To Definition from the opened context menu. Add the following code to the event handler:
private void textControl1_Loaded(object sender, RoutedEventArgs e) { textControl1.Focus(); }
In the XAML, set the DockPanel.Dock property of the RulerBar to Left, the HorizontalAlignment to Left and the VerticalAlignment to Stretch. The full DockPanel XAML code should look like this:
<DockPanel> <WPF:ButtonBar x:Name="buttonBar1" /> <WPF:RulerBar x:Name="rulerBar1" /> <WPF:StatusBar x:Name="statusBar1"/> <WPF:RulerBar x:Name="rulerBar2" DockPanel.Dock="Left" HorizontalAlignment="Left" VerticalAlignment="Stretch"/> <WPF:TextControl Name="textControl1" Loaded="textControl1_Loaded" ButtonBar="buttonBar1" StatusBar="statusBar1" RulerBar="rulerBar1" VerticalRulerBar="rulerBar2"/> </DockPanel>
-
Now, press F5 to compile and start the application.
WPF
Text Control combines the power of a reporting tool and an easy-to-use WYSIWYG word processor - fully programmable and embeddable in your WPF application. TX Text Control .NET for WPF is a royalty-free, fully programmable rich edit control that offers developers a broad range of word processing features in a reusable component for Visual Studio.
Related Posts
Official TX Text Control .NET Sample Applications Are Now Hosted on GitHub
This article gives a quick overview of the new repositories, their structure and our plans for the future.
Getting Started with WPF (.NET Framework)
This article shows how to use the TX Text Control WPF.TextControl class within a .NET Framework 4.8 application in Visual Studio 2022.
Windows FormsGetting Started.NET 6
Getting Started with Windows Forms (.NET 5 and better)
This article shows how to use the TX Text Control .NET for Windows Forms TextControl class within a .NET 6 application in Visual Studio 2022.
Windows Forms and WPF Comeback: .NET 6 and 7. Our Commitment to Windows…
Windows Forms was introduced in the first version of .NET and Visual Studio in 2001. Since then it has grown in popularity specifically for rapid, WYSIWYG development. With the release of .NET…
Visual Studio 2022 and .NET 5, 6 and 7 (Preview) Support and Strategy
With the release of TX Text Control 31.0, we will fully support .NET 5, 6 and 7 (Preview) within Visual Studio 2022 including Windows Forms designer support, NuGet packages and deployment support.