Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
700
Edit value with space in a templated XamCheckEditor
posted

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

Parents
No Data
Reply
  • 34810
    Offline posted

    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

Children