# Create a .NET Framework Application

> Build the Simple sample in a WPF App (.NET Framework) project: TextControl, bars and a menu for files, clipboard and font dialogs, licensed with licenses.licx.

- **Product:** TX Text Control .NET for WPF
- **Section:** Documentation
- **Kind:** Topic
- **Path:** TX Text Control .NET for WPF > Getting Started > Document Editor > Create a .NET Framework Application
- **2918 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-editor/dotnet-framework/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-editor/dotnet-framework/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-editor/dotnet-framework/llms-full.txt

---

Many WPF applications in production still target the .NET Framework 4.8, and TX Text Control .NET for WPF runs in them as well. You build the small word processor of the Simple sample that the setup installs: a `TextControl` with a button bar, rulers and a status bar, and a menu that opens and saves files, uses the clipboard and shows the formatting dialog boxes. The XAML and the code are the same as in a .NET project; the references and the license reach the project in a different way.

### Prerequisites

- Visual Studio on Windows with the .NET Framework 4.8. See [.NET and .NET Framework](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/installation/requirements/dotnet/llms-full.txt).
- The setup of TX Text Control .NET for WPF 34.0, the full or the trial version. For .NET Framework projects, it provides the assemblies, the license and the toolbox tab. See [Installing the Product](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/installation/setup/llms-full.txt).

### Create the Project

1. Open Visual Studio and create a new project.
2. Select **C#** from the **Languages** list, **Windows** from the **Platform** list and **Desktop** as the **Project Type**.
3. Select the project template **WPF App (.NET Framework)** and click **Next**.

    ![The Create a new project dialog of Visual Studio with the template WPF App (.NET Framework) selected.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-wpf/vs-new-project-netfx.e1829889.webp)
4. Enter a project name, select **.NET Framework 4.8** in the **Framework** list and click **Create**.

No NuGet package is installed: in a .NET Framework project, the assemblies come from the installation of the setup.

### Build the Window

The window is built exactly as in the .NET tutorial. In short:

1. In *MainWindow.xaml*, replace the `Grid` with a `DockPanel`.
2. In the toolbox tab **TX Text Control 34.0**, double-click **ButtonBar**. Visual Studio adds a reference to *TXTextControl.WPF* and asks you to restart the XAML Designer: click **OK**, then choose **Build** > **Build Solution**.
3. With the window selected, double-click **RulerBar**, **StatusBar**, a second **RulerBar** and **TextControl**, in this order.
4. Remove the `Height` and `Width` attributes of the new elements and name them `buttonBar1`, `rulerBar1`, `statusBar1`, `rulerBar2` and `textControl1`.
5. Set **DockPanel.Dock** of `rulerBar2` to **Left**, its **HorizontalAlignment** to **Left** and its **VerticalAlignment** to **Stretch**.
6. Select `textControl1` and set its properties **ButtonBar** to `buttonBar1`, **RulerBar** to `rulerBar1`, **StatusBar** to `statusBar1` and **VerticalRulerBar** to `rulerBar2`.

[Create Your First WPF Application](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-editor/first-application/llms-full.txt) shows each of these steps with screenshots and explains why the order matters.

### Add a Menu

A WPF `Menu` at the top of the window gives the editor its commands. It has to be the first child of the `DockPanel`, so that it is docked above the button bar.

1. In the toolbox, find the WPF control **Menu** and double-click it.
2. In the XAML, move the `Menu` element to the top of the `DockPanel`, remove its `Width` and `Height` attributes and set `DockPanel.Dock="Top"`:

    ![The XAML of the DockPanel with the Menu element as its first child, docked at the top, followed by the button bar, the rulers, the status bar and the TextControl.](https://docs.textcontrol.com/assets/img/tx-text-control-dotnet-wpf/xaml-menu-in-dockpanel.34789724.webp)
3. Replace the `Menu` element with the following XAML, which adds the menus **File**, **Edit** and **Format**:

    ```xml
    <Menu x:Name="menu1" DockPanel.Dock="Top">
        <MenuItem Header="_File">
            <MenuItem Header="_Open..." Click="MenuItemOpen_Click" />
            <MenuItem Header="Save _As..." Click="MenuItemSaveAs_Click" />
            <Separator />
            <MenuItem Header="E_xit" Click="MenuItemExit_Click" />
        </MenuItem>
        <MenuItem Header="_Edit">
            <MenuItem Header="Cu_t" Click="MenuItemCut_Click" />
            <MenuItem Header="_Copy" Click="MenuItemCopy_Click" />
            <MenuItem Header="_Paste" Click="MenuItemPaste_Click" />
        </MenuItem>
        <MenuItem Header="F_ormat">
            <MenuItem Header="_Character..." Click="MenuItemCharacter_Click" />
            <MenuItem Header="_Paragraph..." Click="MenuItemParagraph_Click" />
        </MenuItem>
    </Menu>
    ```
4. Add `Loaded="textControl1_Loaded"` to the `WPF:TextControl` element.

### Write the Menu Handlers

Open *MainWindow.xaml.cs*, for example by right-clicking `MenuItemOpen_Click` in the XAML and choosing **Go To Definition**, and add the handlers to the class `MainWindow`:

```csharp
private void textControl1_Loaded(object sender, RoutedEventArgs e)
{
    textControl1.Focus();
}

private void MenuItemOpen_Click(object sender, RoutedEventArgs e)
{
    // Show the Open dialog box and load the file the user selects
    textControl1.Load();
}

private void MenuItemSaveAs_Click(object sender, RoutedEventArgs e)
{
    // Show the Save As dialog box and save to the file the user selects
    textControl1.Save();
}

private void MenuItemExit_Click(object sender, RoutedEventArgs e)
{
    Close();
}

private void MenuItemCut_Click(object sender, RoutedEventArgs e)
{
    textControl1.Cut();
}

private void MenuItemCopy_Click(object sender, RoutedEventArgs e)
{
    textControl1.Copy();
}

private void MenuItemPaste_Click(object sender, RoutedEventArgs e)
{
    textControl1.Paste();
}

private void MenuItemCharacter_Click(object sender, RoutedEventArgs e)
{
    // Font, size and other character attributes of the selection
    textControl1.FontDialog();
}

private void MenuItemParagraph_Click(object sender, RoutedEventArgs e)
{
    // Indents, spacing and alignment of the current paragraph
    textControl1.ParagraphFormatDialog();
}
```

The code works as follows:

- [Load](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/load-method/llms-full.txt) without parameters opens the **Open** dialog box and replaces the contents of the editor with the file the user selects. [Save](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/save-method/llms-full.txt) without parameters opens the **Save As** dialog box.
- [Cut](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/cut-method/llms-full.txt), [Copy](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/copy-method/llms-full.txt) and [Paste](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/paste-method/llms-full.txt) exchange the selection with the clipboard.
- [FontDialog](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/fontdialog-method/llms-full.txt) and [ParagraphFormatDialog](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/textcontrol/paragraphformatdialog-method/llms-full.txt) open the built-in dialog boxes for character and paragraph formatting.

### Run the Application

Press **F5**. The window shows the menu, the button bar, the rulers, the editor and the status bar. Type some text, format it with **Format** > **Character...**, and save it with **File** > **Save As...**.

The same XAML and code build in a .NET project with the package `TXTextControl.TextControl.WPF.SDK`.

### What Is Different in a .NET Framework Project

- **The assemblies come from the setup.** The project references *TXTextControl.WPF.dll* and *TXTextControl.dll* in the *Assembly* folder of the TX Text Control installation. Visual Studio adds the reference to *TXTextControl.WPF* when you add the first control. If your code uses types of the namespace `TXTextControl` and the reference to *TXTextControl.dll* is missing, add it with **Project** > **Add Reference...**.
- **The license comes through licenses.licx.** The license compiler reads the entries of *licenses.licx* and embeds the license into your executable when you build. The file needs an entry for `TXTextControl.WPF.TextControl` with the full version of the assembly you reference, and its build action is **Embedded Resource**; the Simple sample keeps it in the *Properties* folder. If the application reports that a control could not be licensed, see [Licensing](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/troubleshooting/licensing/llms-full.txt) and [Development Licenses](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/installation/licensing/development/llms-full.txt).
- **Deployment is yours.** You ship the assemblies and native libraries with the application. See [Deploying .NET Framework Applications](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/deployment/dotnet-framework/llms-full.txt).

### The Finished Sample

The setup installs this tutorial as a finished project in *%USERPROFILE%\\Documents\\TX Text Control 34.0.NET for WPF\\CSharp\\Tutorial\\Simple*, and in Visual Basic under *VB.NET\\Tutorial\\Simple*.

### Next Steps

- [Load and Save Documents](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-editor/load-save/llms-full.txt): New, Open, Save and Save As with a prompt for unsaved changes.
- [Migrating from .NET Framework to .NET](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/installation/upgrading/from-dotnet-framework/llms-full.txt): move the project to .NET 8 or higher later.
- [Create a WPF Ribbon Application](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-editor/ribbon/llms-full.txt): ribbon tabs instead of the button bar.

---

## Nearby

- **Previous:** [Create Your First WPF Application](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-editor/first-application/llms-full.txt)
- **Next:** [Add TextControl in XAML](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/getting-started/document-editor/xaml/llms-full.txt)
