TX Text Control .NET for Windows Forms Documentation

WPF.LogarithmicConverter Class

The class WPF.LogarithmicConverter Converts a numeric value from a linear scale to a logarithmic scale. It can be used to provide better usability when mapping a zoom factor to a slider, for example. The range of values of the linear as well as the logarithmic scale have to be defined with the given "Minimum"- and "Maximum"-properties. Provides a possibility to define an input value which should be mapped to the center of the output range of values. The class can be used in XAML as a static resource to automatically convert bound property values.

Introduced: 16.0.

Syntax

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

Properties

PropertyDescription
InputCenterSets or gets the numeric value of the source value range which will be mapped to the center of the target value range.
InputMaximumSets or gets the upper bound of the source value range.
InputMinimumSets or gets the lower bound of the source value range.
OutputMaximumSets or gets the upper bound of the target value range.
OutputMinimumSets or gets the lower bound of the target value range.

Methods

MethodDescription
ConvertConverts an integer or a double precision floating point value to an integer or a double precision floating point value.
ConvertBackConverts an integer or a double precision floating point value to an integer or a double precision floating point value.

Example

The following XAML example shows how to bind the TextControl.ZoomFactor property to a slider using the LogarithmicConverter mapping a zoom range from 10 to 400 percent to a value range from 0 to 100.

…
xmlns:tx="clr-namespace:TXTextControl.WPF;assembly=TXTextControl.WPF"
…
<Window.Resources>
   <tx:LogarithmicConverter
      x:Key="logConv"
      InputMinimum="10"
      InputCenter="100"
      InputMaximum="400"
      OutputMinimum="0"
      OutputMaximum="100" />
</Window.Resources>
…
<Slider
   Minimum="0"
   Maximum="100"
   Value="{Binding ElementName=textControl1, Path=ZoomFactor, Converter={StaticResource logConv}}" />

See Also

 
 
 

Products

Support

Downloads

Corporate

Buy Now