locked
Why Expression Blend 3 does not record my color animation? RRS feed

  • Question

  • Hi all,

    I have a very simple project with a button and 2 brushes inside

    <Window
      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" mc:Ignorable="d" xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" x:Class="ComboBoxTest.Window1"
      Title="Window1" Height="300" Width="300">
    	<Window.Resources>
    		<SolidColorBrush x:Key="OriginalColor" Color="#FFEC7171"/>
    		<SolidColorBrush x:Key="OverColor" Color="#FFEC3737"/>
    	</Window.Resources>
      <Grid>
      	<Grid.RowDefinitions>
      		<RowDefinition Height="0.629*"/>
      		<RowDefinition Height="0.371*"/>
      	</Grid.RowDefinitions>
    		<Button x:Name="button" Margin="64,48,90,56.056" Content="Button" Background="{DynamicResource OriginalColor}"/>
    	</Grid>
    </Window>
    
    

    I try to add an color animation in Expression Blend 3 to change color from "OriginalColor" to "OverColor" when mouse moves over the button. The initial style of the button is "OriginalColor".

    Following are the steps I did:

    1) Add a new storyboard:

    2) Select button control, move timeline to 0.6s

    3) Select "OverColor" from brush window

    But from here Expression Blend just created an empty storyboard for me, but does not generate color animation.

    	<Window.Resources>
    		<SolidColorBrush x:Key="OriginalColor" Color="#FFEC7171"/>
    		<SolidColorBrush x:Key="OverColor" Color="#FFEC3737"/>
    		<Storyboard x:Key="MouseOver"/>
    	</Window.Resources>
    

    What did I do wrong?

    Thanks

    Hardy


    Welcome to help me with my open source project at http://code.google.com/p/batch-image-watermark-processor/
    • Moved by Linda Liu Monday, August 9, 2010 9:22 AM (From:Windows Presentation Foundation (WPF))
    Friday, August 6, 2010 11:46 PM

All replies

  • Hi,

    Are you using property trigger, Try this

    <Style x:Key="myStyle" TargetType="{x:Type Button}"> 

    ......


        <Style.Triggers> 
           
    <Trigger Property="IsMouseOver" Value="True"> 
               
    <Setter Property="Background" Value="{StaticResource OverColor}" /> 
           
    </Trigger> 
       
    </Style.Triggers> 
    </Style> 


    Syed Mustehsan Ikram
    Sunday, August 8, 2010 9:13 AM
  • Thanks.

    Your solution will work definetely, but what I try to achieve is color animation that to transit from one brush to the other in 0.6 seconds, but not instantly.

     


    Welcome to help me with my open source project at http://code.google.com/p/batch-image-watermark-processor/
    Monday, August 9, 2010 11:04 PM
  • This is a guess from your screenshots, but it doesn't look like you added any keyframes to your storyboard. Place the time at 0, and press the button to the left of the time indicator, then move the time to .6, add another keyframe, and set your color in that keyframe.
    Tuesday, August 10, 2010 2:13 PM
    Moderator
  • Thanks,

    It works, but I only can set new color specifically. Is there a way I can use pre-defined brush resource?

    Thanks

    Hardy


    Welcome to help me with my open source project at http://code.google.com/p/batch-image-watermark-processor/
    Tuesday, August 10, 2010 11:59 PM