TX Text Control .NET for Windows Forms Documentation

WPF.MeasureConverter Class

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.

Introduced: 16.0.

Syntax

[C#] [ValueConversion(typeof(int), typeof(string))] [ValueConversion(typeof(int), typeof(double))] public class MeasureConverter : IValueConverter
[Visual Basic] Public Class MeasureConverter Implements IValueConverter

Properties

PropertyDescription
DecimalsGets or sets the number of decimals for the converted value.
ShowAllDecimalsGets or sets a value specifying whether all decimals set with the Decimals property are shown, when the result is a string.
UnitGets or sets the measuring unit for the conversion.

Methods

MethodDescription
ConvertConverts a value from twips to another meaasuring unit.
ConvertBackConverts a value from another measuring unit to twips.

Example

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}" />

See Also

 
 
 

Products

Support

Downloads

Corporate

Buy Now