how can I make the checkbox non focusable?

Posted 8 years ago by Avatar Christoph Braendle
how can I make (for all controls) the checkbox (that I have displayed) to be non focusable. the focus should reach the first editable part (after the checkbox).
I'd like to do it in codebehind rather than having a template, possible?


Comments (3)

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
If you are setting the focus manually, you can use our VisualTreeHelperExtended to find the first focusable element that is not a CheckBox.

If you want to ensure the CheckBox never receives focus, then you'd need to use a custom DataTemplate and set the CheckBoxTemplate property. You can do this in XAML or programmatically.

Hope this helps.

Actipro Software Support
Posted 8 years ago by Christoph Braendle
well this is not so easy, at least with my knowledge I dont even know where to start.

I am a little confused why the default behaviour of a standard DateTime-Control is not to be achieved out of the box. By default behaviour I talk of the CheckBox never gets the focus and either entering a date or hitting the spacebar will toggle the CheckBox.

Can you provide a sample of the CheckBoxTemplate that would just let the Checkbox beeing never focused?

Posted 8 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Christoph,

We actually tried to mimic the native WinForms DateTimePicker in that respect, which also has the CheckBox as a focusable/tab stop control. In addition, it will only toggle the CheckBox when the CheckBox has focus, like ours.

In our DateTimeEditBox, if the CheckBox is not checked (or not even visible) you can still tab over to start entering data. If you set IsNullAllowed to true, then you can "null out" the value using Ctrl+A (select all) and pressing the Delete key.

You can define the following DataTemplate and assign it to the CheckBoxTemplate property to make the CheckBox not a tab stop:

<DataTemplate x:Key="CustomCheckBoxTemplate">
    <CheckBox VerticalAlignment="Center" Padding="0" IsTabStop="False"
            Style="{DynamicResource {x:Static themes:EditorsCommonDictionary.CheckBoxStyleKey}}"
            IsChecked="{Binding IsChecked, RelativeSource={x:Static editors:PartEditBox.RelativeSource}}" />

Actipro Software Support
Information The latest build of this product (2017.2 build 0660) was released 14 days ago, which was after the last post in this thread.

Add a Comment

Please log in to a validated account to post comments.