# Creating a WPF Ribbon Application

> This tutorial demonstrates building a WPF ribbon application with TX Text Control .NET for WPF. It covers replacing the default Grid with a DockPanel, adding RibbonFormattingTab and RibbonInsertTab, connecting ruler bars and a status bar, and wiring the ribbon tabs via XAML properties.

- **Author:** Bjoern Meyer
- **Published:** 2020-01-01
- **Modified:** 2026-03-05
- **Description:** This chapter shows you how to create a small word processor with a ribbon interface from scratch with just a few lines of code.
- **3 min read** (574 words)
- **Tags:**
  - WPF
  - Tutorial
- **Web URL:** https://www.textcontrol.com/blog/2020/01/01/creating-a-wpf-ribbon-application/
- **LLMs URL:** https://www.textcontrol.com/blog/2020/01/01/creating-a-wpf-ribbon-application/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2020/01/01/creating-a-wpf-ribbon-application/llms-full.txt

---

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

1. Assuming that you have already run the TX Text Control installation program, start Visual Studio .NET 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/k/assets/n_wpf_ribbon_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/k/assets/n_wpf_ribbon_2.webp "image")
3. Click *Choose Toolbox Items...* from the *Tools* main menu to customize the toolbox. In the tab *WPF Components*, filter for *Ribbon* and find the *Ribbon* from the assembly *System.Windows.Controls.Ribbon*. Select the control and confirm with *OK*.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/k/assets/n_wpf_ribbon_3.webp "image")
4. Find the recently added control *Ribbon*, drag and drop it into the *DockPanel*.
5. Find the controls *RibbonFormattingTab* and *RibbonInsertTab* in the toolbox group *TX Text Control 29.0*, drag and drop them into the created *Ribbon* tag. Add a *name* parameter to both controls and name them *ribbonFormattingTab* and *ribbonInsertTab*. Additionally, set the *Header* parameter to *Home* and *Insert*. The XAML should look like this now:
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/k/assets/n_wpf_ribbon_4.webp "image")
6. In the next steps, the order in the controls are added to the Window is important.
    
    Double-click the *RulerBar* in the toolbox to add it to the Window. Repeat this for the *StatusBar*, a second *RulerBar* and finally *TextControl*. Set the *DockPanel.Dock* property of the first *RulerBar* to top, set *Bottom* for the *StatusBar*, *Left* for the second *RulerBar* and finally *Top* for *TextControl*. Make sure that all other automatically created parameters such as *Width*, *Height* or *Margin* is removed from the tags.
    
    For the secondly added *RulerBar*, set the *HorizontalAlignment* to *Left* and the *VerticalAlignment* to *Stretch*.
    
    Now, add a *Name* for each control according to the following screenshot:
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/k/assets/n_wpf_ribbon_5.webp "image")
7. In this step, the controls must be connected. Therefore, select *textControl* to open it's properties in the *Properties* window of Visual Studio. First, look for the *RulerBar* property and type in the name of the added *RulerBar*: *rulerBar*.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/k/assets/n_wpf_ribbon_6.webp "image")
8. Set the *StatusBar* property to *statusBar* and *VerticalRulerBar* to *verticalRulerBar*.
9. Now, the ribbon tabs must be connected. Find the *RibbonFormattingTab* property and set it to *ribbonFormattingTab*, the name of the insert ribbon tab control. Repeat this step for the *RibbonInsertTab* and set it to *ribbonInsertTab*.
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/k/assets/n_wpf_ribbon_7.webp "image")
    
    The design view of the Window should now look like in the following screenshot:
    
    ![image](https://s1-www.textcontrol.com/assets/dist/blog/2020/01/01/k/assets/n_wpf_ribbon_8.webp "image")
10. In the XAML, add the *Loaded="textControl\_Loaded"* event handler to the textControl element as a parameter, so that the line looks like this:
    
    ```
    <WPF:TextControl DockPanel.Dock="Top" Name="textControl" Loaded="textControl_Loaded" RulerBar="rulerBar" StatusBar="statusBar"
            VerticalRulerBar="verticalRulerBar" RibbonFormattingTab="ribbonFormattingTab" RibbonInsertTab="ribbonInsertTab"/>
    ```
    
    Now, in the XAML right-click on *textControl\_Loaded* and choose *Go To Definition* from the opened context menu. Add the following code to the event handler:
    
    ```
    private void textControl_Loaded(object sender, RoutedEventArgs e) { 
      textControl.Focus();
    }
    ```
    
     ```
    Private Sub textControl_Loaded(sender As Object, e As RoutedEventArgs)
        textControl.Focus()
    End Sub
    ```

---

## 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 Your First WPF Application](https://www.textcontrol.com/blog/2020/01/01/creating-your-first-wpf-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)
