Changing FocusVisualStyle doesn't affect the control

2 posts, 0 answers
  1. Oliver
    Oliver avatar
    263 posts
    Member since:
    Feb 2011

    Posted 10 Apr 2012 Link to this post


    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}" />                       
  2. Dani
    Dani avatar
    848 posts

    Posted 12 Apr 2012 Link to this post

    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 >>
Back to Top