Hello,
when I use the DataTree with a XamNumericEditor (using NodeLayout.ItemTemplate) and I press + or - key, the key is not shown but the TreeNodes are expanding or collapsing. Is there a way to deactivate the expanding/collapsing behaviour of the tree so that +/- is always send to the XamNumericEditor?
See attached sample.
Hello Markus,
Thank you for contacting Infragistics. You can cancel the NodeExpansionChanging event on the DataTree to prevent the nodes collapsing. If you require additional assistance, please provide a sample demonstrating the issue and I'll investigate this further.
Let me know if you have any questions.
when using the NodeExpansionChanging event, and I set e.Cancel = false, then I can't expand/collapse the node anymore. I just want to deactivate the (keyboard) keys + and -. So when the user presses - or + on the keyboard (while the cursor is in the textbox) the node should not expand/collapse, but clicking on the node expand/collapse icon on the left side, the user should be able to trigger that action.
All you have to do is add command bindings for your textbox. This won't interfere with expanding the nodes.
eg. Update the stackpanel in MainWindow.xaml
<TextBox Text="{Binding Data.Value}" Width="50">
<TextBox.InputBindings>
<KeyBinding Command="{Binding Data.IncValueCommand}" Key="Add" />
<KeyBinding Command="{Binding Data.DecValueCommand}" Key="Subtract" />
</TextBox.InputBindings>
</TextBox>
<Button Content="-" Width="20" Command="{Binding Data.DecValueCommand}"/>
<Button Content="+" Width="20" Command="{Binding Data.IncValueCommand}"/>
Not quit correct. In the TextBox I just want to type e.g. -15, instead of clicking the minus button 15 times. So when I press the minus (-) key, the number should get a negative prefix.
In the commands you should calculate and update the value by either adding double or subtracting double of the current value to switch the sign.
I didn't get you. Please modify my attached example in order to show me how to put a minus number in the textbox of the data tree?
I just want to enter e.g. -12 in the textbox of the data tree, with the keyboard.
It sounds like you are looking to change the positive/negative sign of the number when the + or - key is pressed in the TextBox that you are currently placing in your XamDataTree nodes. If this is not the case, please let me know as the following is based on that impression.
Going from Michael's KeyBinding idea, I have devised a pair of new ICommands for use with them, in which I pass the TextBox as a CommandParameter. In the command's Execute method, I would recommend that you parse the value in your TextBox and change the sign based on which key was pressed and then reassign it to the Text property of your TextBox.
I have attached a modified version of the original sample project you sent to demonstrate the above. I hope this helps.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer