Hey,
we are using a style for XamCheckEditor with a ControlTemplate that contains a checkbox:
<Style TargetType="{x:Type igEditors:XamCheckEditor}" x:Key="ForensicsCheckboxStyle"> <Setter Property="IsChecked" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=DataContext.DataItem.ForensicsChecked, Mode=TwoWay}"/> <Setter Property="IsThreeState" Value="False"/> <Setter Property="IsEnabled" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=Field.Settings.AllowEdit}"/> <Setter Property="IsAlwaysInEditMode" Value="True"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igEditors:XamCheckEditor}"> <CheckBox HorizontalAlignment="Center" IsChecked="{Binding RelativeSource={RelativeSource TemplatedParent},Path=IsChecked, Mode=TwoWay}" Background="Tomato" IsHitTestVisible="False" /> </ControlTemplate> </Setter.Value> </Setter> </Style>
We need this style to get a classic checkbox look:
With this style the checkbox can't be set with space by pressing Tab because the checkbox has no focus.
We tried to set the focus in code but it doesn't work.
Have you got an idea how we can fix this behavior?
Best Regards
Lukas
Hello Andrew,
handling the CellActivated event works fine.
Thank you very much
Hello Lukas,
It appears that I had misread this, and missed the whole “tab navigation” part of your original post. I apologize for that.
I believe the reason that this isn’t working by default is because you have removed the ValueEditorCheckBox element by re-templating the XamCheckEditor. This is the element that is normally within the XamCheckEditor’s template, but if you want it to look like a normal CheckBox, it does need to be removed. The problem is that the ValueEditoCheckBox knew when it was embedded in a XamDataGrid cell – the CheckBox element won’t and so it doesn’t focus by default.
As such, I would recommend handling the CellActivated event of the XamDataGrid. Inside, you can check the e.Cell.Field for one of your CheckBox fields (where ‘e’ is the event arguments). If this is the case, you can get the CellValuePresenter element from the static CellValuePresenter.FromCell method, and then use the Infragistics.Windows.Utilities class and its “GetDescendantFrom…” methods to get the Checkbox and manually focus it.
I am attaching a modified version of the original sample project I sent you to demonstrate.
Please let me know if you have any other questions or concerns on this matter.
4682.XDGCheckEditorRetemplateDemo.zip
Hey Andrew,
thanks for the sample but your sample also doesn't work. When you press tab into the retemplated XamDataEditor, pressing space key doesn't check the checkbox.
It looks like the CellValuePresenter doesn't get the focus.
I have been investigating into the code you have provided, and I have put together a simple sample project using it. I believe the main issue here is that the IsHitTestVisible property is set to false. I set a couple of properties differently in this case as well, but setting IsHitTestVisible to false will not let keyboard operations be recognized in the CheckBox.
I am attaching the sample project I used to test this. I hope it helps you.
XDGCheckEditorRetemplateDemo.zip