This is a migrated thread and some comments may be shown as answers.

Changing FocusVisualStyle doesn't affect the control

1 Answer 157 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Oliver asked on 10 Apr 2012, 04:45 PM

in my form, I created a FocusVisualStyle for my control. For my TextBox it work but for Telerik RadDatePicker it doesn't work :(
I want to know how I can change teh FocusVisualStyle of Telerik controls to have the same than the standard controls.

PS: You have to keep in mind that all my forms reside in a DLL which is called by a WinFrom application ;)

Here is part of my xaml:

            <ControlTemplate x:Key="FocusTemplate" >
                <Rectangle Margin="-3" Stroke="Orange" StrokeThickness="2" RadiusX="2" RadiusY="2" StrokeDashArray="2,1">
                        <EventTrigger RoutedEvent="Rectangle.Loaded">
                                    <DoubleAnimation To="3" Duration="0:0:1" RepeatBehavior="Forever" Storyboard.TargetProperty="StrokeDashOffset" />

            <Style x:Key="FocusStyle" TargetType="{x:Type Control}">
                <Setter Property="Template" Value="{StaticResource FocusTemplate}"/>

            <Style TargetType="TextBox">
                <Setter Property="FocusVisualStyle" Value="{StaticResource FocusStyle}"/>

            <Style TargetType="telerik:RadDatePicker">
                <Setter Property="FocusVisualStyle" Value="{StaticResource FocusStyle}"/>

            <helper:BoolToVisibility x:Key="boolToVisibility" />
            <helper:BoolToVisibilityInverter x:Key="boolToVisibilityInverter" />
            <helper:BoolInverter x:Key="boolInverter" />
                <ResourceDictionary Source="BillingDetails-Fr-Res.xaml"/>
                <ResourceDictionary Source="pack://application:,,,/Resources;component/Neuron-CustomStyles.xaml"/>

<telerik:RadDatePicker Grid.Column="3" Grid.Row="0" Margin="5 5 0 0" HorizontalAlignment="Left" IsEnabled="{Binding ElementName=Me, Path=IsReadOnly, Converter={StaticResource boolInverter}}" SelectedValue="{Binding ElementName=Me, Path=Visit.VisitDate, Mode=TwoWay}" />                       

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 12 Apr 2012, 02:33 PM
Hello Oliver,

RadControls use their own focus visuals which are animated in the visual states of the controls (or triggers). The native FocusVisualStyle is therefore set to null.

If you wish to customize the focus visual, you need to edit the states for RadDatePicker states and implement your own visual element for this purpose.

Please, refer to the attached sample. Hope it helps.

the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question