# Creating Your First WPF Application

> This tutorial covers building a WPF rich text editor with TX Text Control .NET for WPF. It walks through adding ButtonBar, RulerBar, StatusBar, and TextControl to a DockPanel, setting dock positions and vertical ruler alignment, and connecting all controls via XAML property bindings.

- **Author:** Bjoern Meyer
- **Published:** 2020-01-01
- **Modified:** 2026-03-05
- **Description:** This tutorial shows how to create a WPF  application with TX Text Control .NET for WPF.
- **2 min read** (368 words)
- **Tags:**
  - WPF
  - Tutorial
- **Web URL:** https://www.textcontrol.com/blog/2020/01/01/creating-your-first-wpf-application/
- **LLMs URL:** https://www.textcontrol.com/blog/2020/01/01/creating-your-first-wpf-application/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2020/01/01/creating-your-first-wpf-application/llms-full.txt

---

Creating the project and controls
---------------------------------

1. Start Microsoft Visual Studio and create a new project. Select either *Visual Basic* or *Visual C#* as the project type and *WPF Application* as the template.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/l/assets/tutorial_wpf_richtext_1.webp "image")
2. In the XAML view, replace the *Grid* with a *DockPanel* control as shown in the below screenshot:
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/l/assets/tutorial_wpf_richtext_2.webp "image")
3. Double-click the *ButtonBar* in the toolbox to add it to the Window. 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. The XAML should look like this:
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/l/assets/tutorial_wpf_richtext_3.webp "image")
4. Select the secondly added *RulerBar* rulerBar2 using the mouse in the *Design* view to change the properties in the *Properties* window. Browse for the *DockPanel.Dock* property and change it to Left.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/l/assets/tutorial_wpf_richtext_4.webp "image")
    
    Additionally, set the *HorizontalAlignment* to *Left* and the *VerticalAlignment* to *Stretch*. The *Design* view should look like this:
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/l/assets/tutorial_wpf_richtext_6.webp "image")
5. Now, the controls must be connected. Therefore, select *textControl1* to open it's properties in the *Properties* window of Visual Studio. First, look for the *ButtonBar* property and type in the name of the added *ButtonBar*: *buttonBar1*.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/l/assets/tutorial_wpf_richtext_5.webp "image")
    
    Set the *RulerBar* property to *rulerBar1*, *StatusBar* to *statusBar1* and *VerticalRulerBar* to *rulerBar2*.
6. In the XAML, add the *textControl1\_Loaded* event handler to the *TextControl* element as a parameter, so that the line looks like this:
    
    ```
    <my:TextControl Name="textControl1" Loaded="textControl1_Loaded"
        ButtonBar="buttonBar1" StatusBar="statusBar1" RulerBar="rulerBar1" VerticalRulerBar="rulerBar2"/>
    ```
    
    Now, right-click on *textControl1\_Loaded* and choose *Navigate to Event Handler* from the opened context menu. Add the following code to the event handler:
    
    ```
    private void textControl1_Loaded(object sender, RoutedEventArgs e) 
    { 
       textControl1.Focus(); 
    }
    ```
    
     ```
    private void textControl1_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) 
    { 
       TextControl1.Focus 
    }
    ```
7. Now, press F5 to compile and start the application.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Creating a WPF Ribbon Application](https://www.textcontrol.com/blog/2020/01/01/creating-a-wpf-ribbon-application/llms.txt)
- [Windows Forms and WPF: End a List on Return when Line is Empty](https://www.textcontrol.com/blog/2016/08/26/windows-forms-and-wpf-end-a-list-on-return-when-line-is-empty/llms.txt)
- [Using IFormattedText Objects to Access Elements Across All TextParts in a Document](https://www.textcontrol.com/blog/2016/08/25/using-iformattedtext-objects-to-access-elements-across-all-textparts-in-a-document/llms.txt)
- [TX Text Control 34.0 SP4 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/05/20/tx-text-control-34-0-sp4-is-now-available/llms.txt)
- [TXTextControl.Markdown.Core 34.1.0-beta: Work with Full Documents, Selection, and SubTextParts](https://www.textcontrol.com/blog/2026/04/14/txtextcontrol-markdown-core-34-1-0-beta-work-with-full-documents-selection-and-subtextparts/llms.txt)
- [TX Spell .NET 11.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/04/08/tx-spell-net-11-0-sp1-is-now-available/llms.txt)
- [TX Text Control 34.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2026/02/18/tx-text-control-34-0-sp2-is-now-available/llms.txt)
- [Text Control Private NuGet Feed](https://www.textcontrol.com/blog/2026/02/09/text-control-private-nuget-feed/llms.txt)
- [TX Text Control 34.0 SP1 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/12/03/tx-text-control-34-0-sp1-is-now-available/llms.txt)
- [Introducing TX Text Control 34.0: Your Next Leap in Document Processing](https://www.textcontrol.com/blog/2025/11/10/introducing-tx-text-control-34-0-your-next-leap-in-document-processing/llms.txt)
- [Sneak Peek: TX Text Control 34.0 Coming November 2025](https://www.textcontrol.com/blog/2025/10/02/sneak-peek-tx-text-control-34-0-coming-november-2025/llms.txt)
- [TX Text Control 33.0 SP3 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/08/14/tx-text-control-33-0-sp3-is-now-available/llms.txt)
- [TX Text Control 33.0 SP2 is Now Available: What's New in the Latest Version](https://www.textcontrol.com/blog/2025/06/18/tx-text-control-33-0-sp2-is-now-available/llms.txt)
- [Document Lifecycle Optimization: Leveraging TX Text Control's Internal Format](https://www.textcontrol.com/blog/2025/05/16/document-lifecycle-optimization-leveraging-tx-text-controls-internal-format/llms.txt)
- [Expert Implementation Services for Legacy System Modernization](https://www.textcontrol.com/blog/2025/05/07/expert-implementation-services-for-legacy-system-modernization/llms.txt)
- [Service Pack Releases: What's New in TX Text Control 33.0 SP1 and 32.0 SP5](https://www.textcontrol.com/blog/2025/05/07/service-pack-releases-whats-new-in-tx-text-control-33-0-sp1-and-32-0-sp5/llms.txt)
- [Top 5 Real-World Applications for TX Text Control Document Processing Libraries](https://www.textcontrol.com/blog/2025/04/01/top-5-real-world-applications-for-tx-text-control-document-processing-libraries/llms.txt)
- [DWX Developer Week Moves to Mannheim - And Text Control Is on Board!](https://www.textcontrol.com/blog/2025/03/19/dwx-developer-week-moves-to-mannheim-and-tx-text-control-is-on-board/llms.txt)
- [The Wait is Over: TX Text Control for Linux is Officially Here](https://www.textcontrol.com/blog/2025/03/12/the-wait-is-over-tx-text-control-for-linux-is-officially-here/llms.txt)
- [Full .NET 9 Support in Text Control .NET Components for ASP.NET Core, Windows Forms, and WPF](https://www.textcontrol.com/blog/2024/11/11/full-net-9-support-in-text-control-net-components-for-asp-net-core-windows-forms-and-wpf/llms.txt)
- [Toggle Field Codes in TX Text Control](https://www.textcontrol.com/blog/2024/11/07/toggle-field-codes-in-tx-text-control/llms.txt)
- [Applying and Updating Formatting Styles from Master Templates (DOTX) in DOCX Documents](https://www.textcontrol.com/blog/2024/10/10/applying-and-updating-formatting-styles-from-master-templates-dotx-in-docx-documents/llms.txt)
- [TX Text Control 32.0 Service Pack 4 Released](https://www.textcontrol.com/blog/2024/09/02/tx-text-control-32-0-service-pack-4-released/llms.txt)
- [Windows Forms Tutorial: Create Your First Windows Forms C# Application](https://www.textcontrol.com/blog/2024/08/26/windows-forms-tutorial-create-your-first-windows-forms-csharp-application/llms.txt)
- [Reliably Detect Property Changes in Objects Using Serialization](https://www.textcontrol.com/blog/2024/07/23/reliably-detect-property-changes-in-objects-using-serialization/llms.txt)
