# InputFormat.TopDistance Property

> Gets or sets a top paragraph distance, in twips, at the current input position. If text is selected, the property specifies the top distance of the whole selected text.

- **Product:** TX Text Control .NET for WPF
- **Section:** Reference
- **Kind:** Property
- **Introduced:** 16.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WPF.SDK` (assembly `TXTextControl.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.dll` from the setup
- **Path:** TX Text Control .NET for WPF > Reference > TXTextControl > InputFormat.TopDistance Property
- **764 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputformat/topdistance-property/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputformat/topdistance-property/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputformat/topdistance-property/llms-full.txt

---

### Description

Gets or sets a top paragraph distance, in twips, at the current input position. If text is selected, the property specifies the top distance of the whole selected text.

### Syntax

```csharp
public int? TopDistance { get; set; }
```

```vbnet
Public Property TopDistance As Integer?
```

### Examples

The following XAML example binds the TopDistance property to a text box using the [WPF.MeasureConverter](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/measureconverter/llms-full.txt) class. The value of the top distance is converted to centimeter.

```plaintext
…
xmlns:tx="clr-namespace:TXTextControl.WPF;assembly=TXTextControl.WPF"
…
<Window.Resources>
    <tx:MeasureConverter Unit="Centimeter" x:Key="twipsConv" />
</Window.Resources>
…
<TextBox 
    Text="{Binding
        ElementName=textControl1,
        Path=InputFormat.TopDistance,
        Converter={StaticResource twipsConv},
        Mode=TwoWay}" />
```

The following example changes the formatting applied to text entered at the end of a document by using `InputFormat.TopDistance`.

```csharp
textControl.Text = "Project summary";
textControl.InputPosition = new InputPosition(textControl.Text.Length);
InputFormat inputFormat = textControl.InputFormat;

inputFormat.TopDistance = 720;
if (inputFormat.TopDistance != null)
{
    Console.WriteLine("Input Format: Top Distance is available.");
}
```

```vbnet
textControl.Text = "Project summary"
textControl.InputPosition = New InputPosition(textControl.Text.Length)
Dim inputFormat As InputFormat = textControl.InputFormat

inputFormat.TopDistance = 720
If inputFormat.TopDistance IsNot Nothing Then
    Console.WriteLine("Input Format: Top Distance is available.")
End If
```

### Remarks

The property returns null when the text selection contains multiple paragraphs with different top distances.

The [WPF.MeasureConverter](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol-wpf/measureconverter/llms-full.txt) can be used to convert the property value to another measuring unit.

---

## Nearby

- **Previous:** [InputFormat.TopAligned Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputformat/topaligned-property/llms-full.txt)
- **Next:** [InputFormat.TopFrameLine Property](https://docs.textcontrol.com/tx-text-control-dotnet-wpf/reference/txtextcontrol/inputformat/topframeline-property/llms-full.txt)
