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 Lukas,
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.
Please let me know if you have any other questions or concerns on this matter.
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.