Is it possible to reverse changes made during edition of node if new value is empty or the same?
Something similar to AcceptChanges property in EditModeEnding for XamDataGrid.
Hello Monika,
In order to prevent changes if the NewValue is empty or the same in XamDataTree you can use the NodeEnteringEditMode event to store the old value and NodeExitingEditMode event to access the new value. This way if it does not pass the check you can call the TextBox's Undo method:
string oldValue = "";private void MyTree_NodeEnteringEditMode(object sender, BeginEditingNodeEventArgs e){ oldValue = (e.Node as XamDataTreeNode).Control.Content.ToString();}private void MyTree_NodeExitingEditMode(object sender, TreeExitEditingEventArgs e){ if (e.NewValue.ToString() == "" || e.NewValue.ToString() == oldValue) (e.Node.Control.Content as TextBox).Undo();}
You can test this approach in the attached sample application.
Please let me know if you need more information.
Sincerely,ZhivkoAssociate Software Developer
Hi,
thank you for answer, with little modification it is working :).