WPF, how to get animation to work properly with data trigger

35 Views Asked by At

I've been working with wpf and i wana animate this text block that when you mouse over, background animates to certain color.

Here is the code:

I've tried searching on MDSN and i couldn't find proper answer and what i've tried so far was all in vain.

1

There are 1 best solutions below

0
RisingDeveloper On

Please provide the sample code with which you are facing issue or Here is the sample you can refer and try in your code -

 <Window x:Class="PracticeFlow.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:Practice"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <TextBlock Margin="18,234,5,-2" Grid.RowSpan="3" Text="My Message">
        <TextBlock.Style>
            <Style TargetType="TextBlock">
                <Setter Property= "Foreground" Value="Blue"/>
                <Style.Triggers>
                    <Trigger Property ="IsMouseOver" Value="True">
                        <Setter Property= "Foreground" Value="Red"/>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </TextBlock.Style>
    </TextBlock>
</Window>