MeasureConverter Class
- Namespace
TXTextControl.WPF
- Package
TXTextControl.from the private NuGet feed or Text Control Offline PackagesTextControl. WPF. SDK
- Assembly
TXTextControl.WPF. dll
- Install
dotnet add package TXTextControl..NET 8 and later. For .NET Framework, referenceTextControl. WPF. SDK TXTextControl.from the setup.WPF. dll
- Implements
- IValue
Converter
Description
The MeasureConverter class provides a way to convert a measure in twips (twentieth of a point) to a value in another measuring unit. Twips are the measuring unit used by TXTextControl. Possible conversions are handled through the Unit property. The result of the conversion is a string or a double, which can be used to display the value for the user. This class can be used in XAML as a static resource to automatically convert bound property values.
Syntax
public class MeasureConverter : IValueConverterPublic Class MeasureConverter
Implements IValueConverterExamples
The following XAML example binds the InputFormat.TopDistance property to a text box using the WPF.MeasureConverter class. The value of the top distance is converted to centimeter.
…
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 creates a Measure Converter instance and configures its unit setting for a document workflow.
TXTextControl.WPF.MeasureConverter measureConverter = new();
measureConverter.Unit = MeasuringUnit.CentiInch;Dim measureConverter As New TXTextControl.WPF.MeasureConverter()
measureConverter.Unit = MeasuringUnit.CentiInchMembers
Constructors
| Constructor | Description |
|---|---|
| MeasureConverter | Not described in the reference. public MeasureConverter(); |
Properties
| Property | Description |
|---|---|
| Decimals | Gets or sets the number of decimals for the converted value. |
| ShowAllDecimals | Gets or sets a value specifying whether all decimals set with the Decimals property are shown, when the result is a string. If 3 decimals are set and the value is 15.5, the resulting string contains 15.500 when ShowAllDecimals is true and 15.5 when ShowAllDecimals is false. If the result is a double, this property has no meaning. |
| Unit | Gets or sets the measuring unit for the conversion. |
Methods
| Method | Description |
|---|---|
| Convert | Converts a value from twips to another meaasuring unit. |
| ConvertBack | Converts a value from another measuring unit to twips. |