To reproduce:
1. Create a XamDataTree with some nodes, set AllowEditing to true.2. Run and hit F2 to rename a node (but do not confirm by hitting Enter or clicking outside the TextBox).3. Alt-Tab away and then back.4. The TextBox is still there, the node is still in editing mode.
Instead of step 3, you can add a XamDockManager to the app, create a floating pane and from the node editor TextBox click into the floating pane. The TextBox does not disappear.
Questions:
1. Is this the intended behavior (I would expect a behavior similar to the windows explorer, Alt-Tab confirms the current value in the TextBox)?
2. If no, could you fix it please.
3. If yes, is there an easy way to achieve that Alt-Tab or clicking into a floating pane confirms the value in the TextBox and the node automatically leaves edinting mode?
On a related note:If an ItemTemplate is set for the tree, I always get this error message in the debug window on entering edit mode:
System.Windows.Data Error: 40 : BindingExpression path error: 'Data' property not found on 'object' ''TextBox' (Name='')'. BindingExpression:Path=Data.Title; DataItem='TextBox' (Name=''); target element is 'TextBlock' (Name=''); target property is 'Text' (type 'String')
To reproduce, simply create a tree and set an ItemTemplate like this:
<ig:XamDataTree.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Path=Data.Title}" /> </DataTemplate></ig:XamDataTree.ItemTemplate>
and edit a node while watching the debug window in VS.
The result is OK (the data is indeed changed), but the error message probably isn't intended.
Hello Tjark,
Thank you for your posts. I have been looking into them.
After researching the functionality from your first post, I can tell that this is the default behavior of the xamDataTree.
I have sent your Product Idea directly to our product management team. Our product team chooses new Product Ideas for development based on popular feedback from our customer base. Infragistics continues to monitor application development for all of our products, so as trends appear in requested ideas, we can plan accordingly.
We value your input, and our philosophy is to enhance our toolset based on customer feedback. If your idea is chosen for development, you will be notified at that time. Your reference number for this Product Idea is PI13070031.
If you would like to follow up on your Product Idea at a later point, you may contact Developer Support management via email. Please include the reference number of your Product Idea in the subject and body of your email message. You can reach Developer Support management through the following email address: dsmanager@infragistics.com
For your second post I think I am missing something from your scenario. Would you please attach a simple sample, that reproduces the issue, in order for me to be able to reproduce the issue and provide you with better support. Thank you in advance for the information.
Looking forward to hearing from you.
Hi Gergana,
thanks for your answer.
OK, then I have this question:Can I somehow exit edit mode programmatically?Because I have an application that uses the XamDockManager, and the current behavior of the XamDataTree is that- clicking anywhere in the main window exits edit mode, but- clicking into a floating window within the same application does not exit edit mode.
This feels inconsistent.
For the binding error I have attached a VS solution that demonstrates it.Run in debug mode and watch the output window when hitting F2 to edit a node.
After that, comment the ItemTemplate and do the same again: the error no longer appears.
Since I need to use an ItemTemplate, I was wondering if it was a mistake on my side.
I have been looking into your post. For your first requirement, when you press the ALT+Tab keys I can suggest to handle the StateChanged event of the Window, that contains the xamDataTree. In the event handler of this event you can check if the window goes in minimized mode and if the ALT+Tab keys are pressed, to make the xamDataTree exit edit mode. Using the following line the xamDataTree, should exit edit mode: this.SampleTree.ExitEditMode(true);
For your second requirement about the binding error I have logged this behavior with our developers in our tracking system, with an issue ID of 146465. I have also created a support ticket on your behalf with number CAS-119482-S6B7K0 in order to link the development issue to it so that you are automatically updated when a Service Release containing your fix is available for download.
Please do not hesitate to let me know if you have any further questions on the matter.
Thanks s lot. I totally missed the ExitEditMode() method. That solves my problem.
The other issue is not really an issue because everything works as it should, I just thought I'd report the error message that I am getting.
I created this Blend behavior to solve my problem (it selects all text on entering edit mode and exits edit mode if the TextBox loses focus):
public class SelectAllTextOnGotFocus : Behavior<TextBox>{ protected override void OnAttached() { base.OnAttached(); AssociatedObject.GotKeyboardFocus += AssociatedObjectGotKeyboardFocus; AssociatedObject.LostKeyboardFocus += AssociatedObject_LostKeyboardFocus; } protected override void OnDetaching() { base.OnDetaching(); AssociatedObject.GotKeyboardFocus -= AssociatedObjectGotKeyboardFocus; AssociatedObject.LostKeyboardFocus -= AssociatedObject_LostKeyboardFocus; } private void AssociatedObjectGotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { AssociatedObject.SelectAll(); } private void AssociatedObject_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { DependencyObject d = VisualTreeHelper.GetParent(AssociatedObject); while (d != null) { if (d is XamDataTree) { (d as XamDataTree).ExitEditMode(false); break; } d = VisualTreeHelper.GetParent(d); } }}
It can be attached via the EditorTemplate property of a NodeLayout:
<ig:NodeLayout.EditorTemplate> <DataTemplate> <TextBox Text="{Binding Path=Data.Label, Mode=TwoWay, UpdateSourceTrigger=Explicit}"> <i:Interaction.Behaviors> <local:SelectAllTextOnGotFocus /> </i:Interaction.Behaviors> </TextBox> </DataTemplate></ig:NodeLayout.EditorTemplate>
Thank you for sharing your solution. I think other community members can benefit from this.