how can I make the checkbox non focusable?

Editors for WPF Forum

Posted 15 years ago by Christoph Braendle
Version: 9.1.0505
Avatar
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?

Thanks,
Christoph

Comments (3)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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 15 years ago by Christoph Braendle
Avatar
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?

Regards,
Christoph
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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:
xmlns:editors="http://schemas.actiprosoftware.com/winfx/xaml/editors"
xmlns:themes="http://schemas.actiprosoftware.com/winfx/xaml/themes"

<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}}" />
</DataTemplate>


Actipro Software Support

The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.