I have XamTreeGrid with several template fields. I need to bind LeftDoubleClick to several of them with unique commands bound to each. So I have one general data template for the display of my values and then specific data template to handle each of the LeftDoubleClicks like this:
<DataTemplate x:Key="SpecificValueTemplate" DataType="local:MyDataItem"> <ContentControl ContentTemplate="{StaticResource GeneralValueTemplate}" Content="{Binding SpecificValue}"> <ContentControl.InputBindings> <MouseBinding Gesture="LeftDoubleClick" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=wpf:View}, Path=DataContext.SpecificValueLeftDoubleClickCommand}" CommandParameter="{Binding}" /> </ContentControl.InputBindings> </ContentControl> </DataTemplate>
My problem is that I have to double click my value twice before the command is executed. Am I missing something? My CellClickAction is set to "SelectRecord" and the first double click is selecting and de-selecting the row. The second double click is doing the same + executing the command. I want the command to be executed on the first double click.
Hello Hilma,
I have been investigating into the behavior you are seeing where the first left button double-click is not being picked up by your DataTemplate. If I had to guess at the reason that this behavior is not working on your end, it would be that the XamTreeGrid is “eating” the first click by handling it, but I have not been able to reproduce this behavior as of yet, and so perhaps something is being set in your application that is not being set in my test project.
I have attached the sample project I used to test this. Please test this project on your PC as whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, this indicates either a problem possibly specific to your environment, or a difference in the DLL versions we are using. My test was performed using version 20.2.20202.38 of Infragistics for WPF 2020 Volume 2.
If the project does show the product feature working correctly, this indicates a possible problem in the code of your application. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing.
Or, if this sample project is not an accurate demonstration of what you're trying to do, please feel free to modify it and send it back, or send a small sample project of your own if you have one.
Please let me know if you have any other questions or concerns on this matter.
XamTreeGridDoubleClickTest.zip
Hi Andrew,
When comparing our solutions I saw that you have set AllowEdit = false and when I did that as well it worked! I did not know that I had to do that even if I only and a DisplayTemplate (and no EditTemplate) on my TemplateField. Do you have a link to the documentation for the TemplateField so i can understand this better?
BR,
Hilma Maria
To be honest, setting the AllowEdit to false was just a coincidence here, as I wasn’t sure if the template you had defined was a DisplayTemplate or an EditTemplate. I tested both scenarios, but the sample I sent you was using the DisplayTemplate with no EditTemplate and so I applied this setting. Here is the link to the documentation for TemplateField: https://ko.infragistics.com/help/wpf/xamdatagrid-configuring-template-field.