Version

EndEditMode Method (ValueEditor)

Exits edit mode.
Syntax
'Declaration
 
Public Sub EndEditMode( _
   ByVal acceptChanges As Boolean, _
   ByVal force As Boolean _
) 
public void EndEditMode( 
   bool acceptChanges,
   bool force
)

Parameters

acceptChanges
If True will accept any changes that were made while in edit mode.
force
If True will prevent the cancellation of the action.
Remarks

EndEditMode exits edit mode, validating the user input in the process if acceptChanges is True. If acceptChanges is False then the user input is discarded and the Value is restored back to the original value.

As part of the process of exitting edit mode, EditModeEnding and EditModeEnded events are raised. You can cancel EditModeEnding event to cancel exitting edit mode.

Note: Typically there is no need to call this method directly. The editor will automatically enter and exit edit mode as necessary. For example, when using the editor embedded inside a field of a XamDataGrid, the editor is put into edit mode automatically when the cell is clicked and exits edit mode when the focus leaves the cell. When using the editor as a stand-alone control, the editor will automatically enter edit mode when the editor receives focus (for example via a mouse click or when tabbing into it) and exit edit mode when the editor looses focus. This default behavior can be controlled using the IsAlwaysInEditMode property.

Example
The following code demonstrates OriginalValue and HasValueChanged properties. It also makes use of StartEditMode and EndEditMode to enter and exit edit mode.

Private Sub Button1_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
        ' When edit mode ends, the value will be committed and OriginalValue and
        ' HasValueChanged will be reset.
        Me.textEditor1.EndEditMode(True, False)

        Me.textEditor1.Value = "A"

        ' HasValueChanged and OriginalValue properties are only applicable during
        ' edit mode. These properties are set when the value of the editor is
        ' modified after entering edit mode.
        Me.textEditor1.StartEditMode()

        ' The following will print out 'A' and False respectively.
        Debug.WriteLine("After entering edit mode:")
        Debug.WriteLine("OriginalValue = '" & Me.textEditor1.OriginalValue & "'")
        Debug.WriteLine("HasValueChanged = " & Me.textEditor1.HasValueChanged)

        Me.textEditor1.Value = "B"

        ' The Value was modified to B above. The following will print out 'A' and 
        ' True respectively.
        Debug.WriteLine("After changing value to B:")
        Debug.WriteLine("OriginalValue = '" & Me.textEditor1.OriginalValue & "'")
        Debug.WriteLine("HasValueChanged = " & Me.textEditor1.HasValueChanged)

        ' When edit mode ends, the value will be committed and HasValueChanged will 
        ' be reset.
        Me.textEditor1.EndEditMode(True, False)

        ' The following will print out False.
        Debug.WriteLine("After exiting edit mode:")
        Debug.WriteLine("HasValueChanged = " & Me.textEditor1.HasValueChanged)
    End Sub
public void button1_Click( object sender, RoutedEventArgs e )
{
	// When edit mode ends, the value will be committed and OriginalValue and
	// HasValueChanged will be reset.
	this.textEditor1.EndEditMode( true, false );

	this.textEditor1.Value = "A";

	// HasValueChanged and OriginalValue properties are only applicable during
	// edit mode. These properties are set when the value of the editor is
	// modified after entering edit mode.
	this.textEditor1.StartEditMode( );

	// The following will print out 'A' and False respectively.
	Debug.WriteLine( "After entering edit mode:" );
	Debug.WriteLine( "OriginalValue = '" + this.textEditor1.OriginalValue + "'" );
	Debug.WriteLine( "HasValueChanged = " + this.textEditor1.HasValueChanged );

	this.textEditor1.Value = "B";

	// The Value was modified to B above. The following will print out 'A' and 
	// True respectively.
	Debug.WriteLine( "After changing value to B:" );
	Debug.WriteLine( "OriginalValue = '" + this.textEditor1.OriginalValue + "'" );
	Debug.WriteLine( "HasValueChanged = " + this.textEditor1.HasValueChanged );

	// When edit mode ends, the value will be committed and HasValueChanged will 
	// be reset.
	this.textEditor1.EndEditMode( true, false );

	// The following will print out False.
	Debug.WriteLine( "After exiting edit mode:" );
	Debug.WriteLine( "HasValueChanged = " + this.textEditor1.HasValueChanged );
}
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