Version

Value Property (ValueEditor)

Gets or sets the value of the editor.
Syntax
'Declaration
 
Public Property Value As Object
public object Value {get; set;}
Remarks

The ValueType property specifies the type of values returned and expected by the Value property. For example, if you set the ValueType to Decimal then the Value property will return decimal values. The user input will be converted to Decimal before returning from Value property. The Text property on the other hand always returns the text representation of the value.

Note: Setting the Value property will also update the Text property.

Note: As the user enters/modifies the contents of the ValueEditor, the Text and Value properties will be synchronously updated to reflect the current contents. If the user input can not be parsed into the associated ValueType, the Text property will be updated however the Value property will retain last parsed value. In such a case, the IsValueValid property will return false indicating that the user input is invalid.

Example
The following code demonstrates how Value, Text and DisplayText properties work. It demonstrates their behavior in regards to formatting and auto-conversion capabilities. The XAML code defines a XamTextEditor and a Button. The C#/VB code has the button's click event handler. Code in it sets the Value property property to a float number and prints out the values of Value, Text and DisplayText. Note that the ValueType is set to Decimal and that's why the Value property returns a Decimal even though it was set to a float.

Private Sub Button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Me.textEditor1.ValueType = GetType(Decimal)
    Me.textEditor1.Format = "C"
    Me.textEditor1.FormatProvider = New System.Globalization.CultureInfo("fr-FR")

    ' Even though we are setting the Value property to 10.5 as a float, the
    ' editor will automatically convert the value to type set on ValueType 
    ' property which we set to Decimal above.
    Me.textEditor1.Value = CType(10.5, System.Single)

    ' The Value property will automatically convert and return values of type
    ' set on the ValueType property, which we set above to Decimal.
    Debug.WriteLine("Value = " & Me.textEditor1.Value.ToString() & " as " & Me.textEditor1.Value.GetType().Name)

    ' Text property will return text representation of value without any formatting
    ' applied to it. This is what's going to be displayed when the editor enters
    ' edit mode.
    Debug.WriteLine("Text = " & Me.textEditor1.Text)

    ' DisplayText property will return text representation of value with formatting
    ' applied to it.
    Debug.WriteLine("DisplayText = " & Me.textEditor1.DisplayText)
End Sub
public void button1_Click( object sender, RoutedEventArgs e )
{
	this.textEditor1.ValueType = typeof( Decimal );
	this.textEditor1.Format = "C";
	this.textEditor1.FormatProvider = new System.Globalization.CultureInfo( "fr-FR" );

	// Even though we are setting the Value property to 10.5 as a float, the
	// editor will automatically convert the value to type set on ValueType 
	// property which we set to Decimal above.
	this.textEditor1.Value = (float)10.5;

	// The Value property will automatically convert and return values of type
	// set on the ValueType property, which we set above to Decimal.
	Debug.WriteLine( "Value = " + this.textEditor1.Value.ToString( ) + " as " + this.textEditor1.Value.GetType( ).Name );

	// Text property will return text representation of value without any formatting
	// applied to it. This is what's going to be displayed when the editor enters
	// edit mode.
	Debug.WriteLine( "Text = " + this.textEditor1.Text );

	// DisplayText property will return text representation of value with formatting
	// applied to it.
	Debug.WriteLine( "DisplayText = " + this.textEditor1.DisplayText );
}
<igEditors:XamTextEditor x:Name="textEditor1" />

<Button x:Name="button1"  Click="button1_Click">Click</Button>
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also