Use ColorAnimation to change the background of RadButton

3 posts, 0 answers
  1. Akram
    Akram avatar
    45 posts
    Member since:
    Dec 2012

    Posted 18 Dec 2012 Link to this post

    Hi
    How to Use ColorAnimation to change the background of RadButton when IsMouseOver is True
    , this is my code

    <Style TargetType="telerik:RadButton">
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard >
                                    <ColorAnimation From="Green" To="Yellow" Storyboard.TargetProperty="(Button.Background).(SolidColorBrush.Color)"  Duration="00:00:03" RepeatBehavior="Forever"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                    </Trigger>
                </Style.Triggers>
            </Style>


    But is not working.

    Thanks,
    Akram
  2. Pavel R. Pavlov
    Admin
    Pavel R. Pavlov avatar
    1183 posts

    Posted 21 Dec 2012 Link to this post

    Hi Akram,

    As far as I understand you need to change the default hover effect of the control. Your snippet in not going to work because the default template triggers/visualStates are applied after the style triggers, hence the trigger becomes overridden. In other words you can not apply two styles at the same time.

    In order to customize the default hover state you have to edit the default template of the control. For your convenience I have extracted the template using Blend (as described in this article) in the attached project. Please take a look at it and let me know if it works for you.

    Kind regards,
    Pavel R. Pavlov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Akram
    Akram avatar
    45 posts
    Member since:
    Dec 2012

    Posted 21 Dec 2012 Link to this post

    Thanks for your help, but this is a lot of xaml code, i thought there is a simple way to do that.

    Thanks,
    Akram
Back to Top