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

Changing FocusVisualStyle doesn't affect the control

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

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:

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


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

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

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

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

<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
0
Dani
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.


Regards,
Dani
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Tags
DatePicker
Asked by
Oliver
Top achievements
Rank 1
Answers by
Dani
Telerik team
Share this question
or